* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2012-12-17 05:04:04 +00:00
Родитель 73b244d0de
Коммит 6d8ad6c489
2 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Mon Dec 17 13:56:55 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* 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@segment7.net> Mon Dec 17 12:05:32 2012 Eric Hodel <drbrain@segment7.net>
* doc/syntax/methods.rdoc: Added a description of singleton methods. * doc/syntax/methods.rdoc: Added a description of singleton methods.

24
io.c
Просмотреть файл

@ -975,7 +975,13 @@ io_flush_buffer_sync(void *arg)
static void* static void*
io_flush_buffer_sync2(void *arg) 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 static VALUE
@ -989,17 +995,19 @@ static VALUE
io_flush_buffer_async2(VALUE arg) io_flush_buffer_async2(VALUE arg)
{ {
rb_io_t *fptr = (rb_io_t *)arg; rb_io_t *fptr = (rb_io_t *)arg;
void *ret; VALUE ret;
ret = rb_thread_call_without_gvl2(io_flush_buffer_sync2, fptr, ret = (VALUE)rb_thread_call_without_gvl2(io_flush_buffer_sync2, fptr,
RUBY_UBF_IO, NULL); RUBY_UBF_IO, NULL);
/* pending async interrupt is there. */
if (!ret) { if (!ret) {
/* pending async interrupt is there. */
errno = EAGAIN; errno = EAGAIN;
return (VALUE)-1; return -1;
} } else if (ret == 1) {
return (VALUE) ret; return 0;
} else
return ret;
} }
static inline int static inline int