Project

General

Profile

Bug #4535 ยป 0001-ext-socket-unixsocket.c-fix-race-in-blocking-send_io.patch

normalperson (Eric Wong), 03/29/2011 06:23 AM

View differences:

ext/socket/unixsocket.c
248 248
#endif
249 249

  
250 250
    arg.fd = fptr->fd;
251
    rb_thread_fd_writable(arg.fd);
252
    if ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1)
253
	rb_sys_fail("sendmsg(2)");
251
    while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) {
252
	if (!rb_io_wait_writable(arg.fd))
253
	    rb_sys_fail("sendmsg(2)");
254
    }
254 255

  
255 256
    return Qnil;
256 257
}
......
334 335
#endif
335 336

  
336 337
    arg.fd = fptr->fd;
337
    rb_thread_wait_fd(arg.fd);
338
    if ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1)
339
	rb_sys_fail("recvmsg(2)");
338
    while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
339
	if (!rb_io_wait_readable(arg.fd))
340
	    rb_sys_fail("recvmsg(2)");
341
    }
340 342

  
341 343
#if FD_PASSING_BY_MSG_CONTROL
342 344
    if (arg.msg.msg_controllen < (socklen_t)sizeof(struct cmsghdr)) {
343
-