diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | thread_sync.c | 30 |
2 files changed, 22 insertions, 14 deletions
@@ -1,3 +1,9 @@ +Tue Sep 1 18:16:32 2015 Koichi Sasada <ko1@atdot.net> + + * thread_sync.c (queue_do_close): ignore multiple close to allow + multiple producers. + https://bugs.ruby-lang.org/issues/10600#note-14 + Tue Sep 1 18:06:26 2015 Koichi Sasada <ko1@atdot.net> * thread_tools.c: rename thread_tools.c to thread_sync.c. diff --git a/thread_sync.c b/thread_sync.c index c99f54cb82..21b71702b4 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -619,23 +619,23 @@ queue_do_close(VALUE self, int argc, VALUE *argv, int is_szq) { VALUE exception = Qfalse; - if (queue_closed_p(self)) raise_closed_queue_error(self); + if (!queue_closed_p(self)) { + rb_scan_args(argc, argv, "01", &exception); + FL_SET(self, QUEUE_CLOSED); - rb_scan_args(argc, argv, "01", &exception); - FL_SET(self, QUEUE_CLOSED); - - if (RTEST(exception)) { - FL_SET(self, QUEUE_CLOSE_EXCEPTION); - } + if (RTEST(exception)) { + FL_SET(self, QUEUE_CLOSE_EXCEPTION); + } - if (queue_num_waiting(self) > 0) { - VALUE waiters = GET_QUEUE_WAITERS(self); - wakeup_all_threads(waiters); - } + if (queue_num_waiting(self) > 0) { + VALUE waiters = GET_QUEUE_WAITERS(self); + wakeup_all_threads(waiters); + } - if (is_szq && szqueue_num_waiting_producer(self) > 0) { - VALUE waiters = GET_SZQUEUE_WAITERS(self); - wakeup_all_threads(waiters); + if (is_szq && szqueue_num_waiting_producer(self) > 0) { + VALUE waiters = GET_SZQUEUE_WAITERS(self); + wakeup_all_threads(waiters); + } } return self; @@ -705,6 +705,8 @@ queue_do_push(VALUE self, VALUE obj) * * - +closed?+ will return true * + * - +close+ will be ignored. + * * - calling enq/push/<< will raise ClosedQueueError('queue closed') * * - when +empty?+ is false, calling deq/pop/shift will return an object |