ruby-changes:26371
From: kosaki <ko1@a...>
Date: Mon, 17 Dec 2012 14:04:19 +0900 (JST)
Subject: [ruby-changes:26371] kosaki:r38422 (trunk): * io.c (io_flush_buffer_sync2): avoid to return 0. because
kosaki 2012-12-17 14:04:04 +0900 (Mon, 17 Dec 2012) New Revision: 38422 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38422 Log: * io.c (io_flush_buffer_sync2): avoid to return 0. because rb_thread_call_without_gvl2 uses 0 internally. * io.c (io_flush_buffer_async2): adapt the above. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 38421) +++ ChangeLog (revision 38422) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Dec 17 13:56:55 2012 KOSAKI Motohiro <kosaki.motohiro@g...> + + * io.c (io_flush_buffer_sync2): avoid to return 0. because + rb_thread_call_without_gvl2 uses 0 internally. + * io.c (io_flush_buffer_async2): adapt the above. + Mon Dec 17 12:05:32 2012 Eric Hodel <drbrain@s...> * doc/syntax/methods.rdoc: Added a description of singleton methods. Index: io.c =================================================================== --- io.c (revision 38421) +++ io.c (revision 38422) @@ -975,7 +975,13 @@ io_flush_buffer_sync(void *arg) https://github.com/ruby/ruby/blob/trunk/io.c#L975 static void* io_flush_buffer_sync2(void *arg) { - return (void*)io_flush_buffer_sync(arg); + VALUE result = io_flush_buffer_sync(arg); + + /* + * rb_thread_call_without_gvl2 uses 0 as interrupted. + * So, we need to avoid to use 0. + */ + return !result ? (void*)1 : (void*)result; } static VALUE @@ -989,17 +995,19 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L995 io_flush_buffer_async2(VALUE arg) { rb_io_t *fptr = (rb_io_t *)arg; - void *ret; + VALUE ret; - ret = rb_thread_call_without_gvl2(io_flush_buffer_sync2, fptr, - RUBY_UBF_IO, NULL); + ret = (VALUE)rb_thread_call_without_gvl2(io_flush_buffer_sync2, fptr, + RUBY_UBF_IO, NULL); - /* pending async interrupt is there. */ if (!ret) { + /* pending async interrupt is there. */ errno = EAGAIN; - return (VALUE)-1; - } - return (VALUE) ret; + return -1; + } else if (ret == 1) { + return 0; + } else + return ret; } static inline int -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/