about summary refs log tree commit homepage
path: root/ext/posix_mq/posix_mq.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/posix_mq/posix_mq.c')
-rw-r--r--ext/posix_mq/posix_mq.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 5b7a3ed..e1ad5f1 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -470,7 +470,12 @@ static VALUE send0(VALUE self, VALUE buffer)
         x.timeout = NULL;
         x.msg_prio = 0;
 
-        rv = (mqd_t)rb_thread_blocking_region(xsend, &x, RUBY_UBF_IO, 0);
+        if (mq->attr.mq_flags & O_NONBLOCK)
+                rv = (mqd_t)xsend(&x);
+        else
+                rv = (mqd_t)rb_thread_blocking_region(xsend, &x,
+                                                      RUBY_UBF_IO, 0);
+
         if (rv == MQD_INVALID)
                 rb_sys_fail("mq_send");