Project

General

Profile

Bug #6629 ยป 0001-io.c-avoid-rb_thread_wait_fd-if-we-may-call-rb_io_wa.patch

normalperson (Eric Wong), 06/23/2012 12:04 PM

View differences:

io.c
1907 1907
	    }
1908 1908
	    offset += c;
1909 1909
	    if ((n -= c) <= 0) break;
1910
	    rb_thread_wait_fd(fptr->fd);
1911 1910
	}
1912 1911
	return len - n;
1913 1912
    }
......
1918 1917
	    offset += c;
1919 1918
	    if ((n -= c) <= 0) break;
1920 1919
	}
1921
	rb_thread_wait_fd(fptr->fd);
1922 1920
	rb_io_check_closed(fptr);
1923 1921
	if (io_fillbuf(fptr) < 0) {
1924 1922
	    break;
......
4333 4331
    }
4334 4332

  
4335 4333
    n = fptr->fd;
4334

  
4335
    /*
4336
     * FIXME: removing rb_thread_wait_fd() here changes sysread semantics
4337
     * on non-blocking IOs.  However, it's still currently possible
4338
     * for sysread to raise Errno::EAGAIN if another thread read()s
4339
     * the IO after we return from rb_thread_wait_fd() but before
4340
     * we call read()
4341
     */
4336 4342
    rb_thread_wait_fd(fptr->fd);
4343

  
4337 4344
    rb_io_check_closed(fptr);
4338 4345

  
4339 4346
    io_setstrbuf(&str, ilen);
......
9797 9804
        }
9798 9805
        else {
9799 9806
            ssize_t ss;
9800
            rb_thread_wait_fd(stp->src_fd);
9801 9807
            rb_str_resize(buf, buflen);
9802 9808
            ss = maygvl_copy_stream_read(1, stp, RSTRING_PTR(buf), l, off);
9803 9809
            if (ss == -1)