summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-17 05:04:04 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-17 05:04:04 +0000
commit6d8ad6c489f41dfb5553d0933793eb5c84e0cc29 (patch)
treebee1b8090ee45e7472570fd73586b680c62ab53e /io.c
parent73b244d0ded191337ed6b30eb7ead658b614ae8b (diff)
* 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
Diffstat (limited to 'io.c')
-rw-r--r--io.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/io.c b/io.c
index bfafe636d8..3047da4380 100644
--- a/io.c
+++ b/io.c
@@ -975,7 +975,13 @@ io_flush_buffer_sync(void *arg)
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
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