ruby-changes:26348
From: kosaki <ko1@a...>
Date: Sat, 15 Dec 2012 14:40:19 +0900 (JST)
Subject: [ruby-changes:26348] kosaki:r38399 (trunk): * io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of
kosaki 2012-12-15 14:40:07 +0900 (Sat, 15 Dec 2012) New Revision: 38399 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38399 Log: * io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of io_flush_buffer_async. * io.c (io_flush_buffer_async2): new helper function for io_flush_buffer. It uses rb_thread_call_without_gvl2() instead of rb_thread_io_blocking_region. * io.c (io_flush_buffer_sync2): new helper function for io_flush_buffer_async2. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 38398) +++ ChangeLog (revision 38399) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Dec 15 13:38:30 2012 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (io_flush_buffer): uses io_flush_buffer_async2 instead of + io_flush_buffer_async. + * io.c (io_flush_buffer_async2): new helper function for + io_flush_buffer. It uses rb_thread_call_without_gvl2() instead + of rb_thread_io_blocking_region. + * io.c (io_flush_buffer_sync2): new helper function for + io_flush_buffer_async2. + Sat Dec 15 13:04:26 2012 KOSAKI Motohiro <kosaki.motohiro@g...> * io.c (internal_write_func2): new helper function for rb_write_internal2(). Index: io.c =================================================================== --- io.c (revision 38398) +++ io.c (revision 38399) @@ -972,6 +972,12 @@ io_flush_buffer_sync(void *arg) https://github.com/ruby/ruby/blob/trunk/io.c#L972 return (VALUE)-1; } +static void* +io_flush_buffer_sync2(void *arg) +{ + return (void*)io_flush_buffer_sync(arg); +} + static VALUE io_flush_buffer_async(VALUE arg) { @@ -979,11 +985,28 @@ io_flush_buffer_async(VALUE arg) https://github.com/ruby/ruby/blob/trunk/io.c#L985 return rb_thread_io_blocking_region(io_flush_buffer_sync, fptr, fptr->fd); } +static VALUE +io_flush_buffer_async2(VALUE arg) +{ + rb_io_t *fptr = (rb_io_t *)arg; + void *ret; + + ret = rb_thread_call_without_gvl2(io_flush_buffer_sync2, fptr, + RUBY_UBF_IO, NULL); + + /* pending async interrupt is there. */ + if (!ret) { + errno = EAGAIN; + return (VALUE)-1; + } + return (VALUE) ret; +} + static inline int io_flush_buffer(rb_io_t *fptr) { if (fptr->write_lock) { - return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async, (VALUE)fptr); + return (int)rb_mutex_synchronize(fptr->write_lock, io_flush_buffer_async2, (VALUE)fptr); } else { return (int)io_flush_buffer_async((VALUE)fptr); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/