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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 5e1b3b8..0567676 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -824,7 +824,15 @@ static VALUE setattr(VALUE self, VALUE astruct)
  */
 static VALUE _close(VALUE self)
 {
-        struct posix_mq *mq = get(self, 1);
+        struct posix_mq *mq;
+
+        if (IDEMPOTENT_IO_CLOSE) { /* defined in extconf.rb */
+                mq = get(self, 0);
+                if (!mq || (mq->des == MQD_INVALID))
+                        return Qnil;
+        } else {
+                mq = get(self, 1);
+        }
 
         if (! MQ_IO_CLOSE(mq)) {
                 if (mq_close(mq->des) < 0)