summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-01 09:17:28 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-01 09:17:28 +0000
commitc37c67cef8f9aef160b198db4b100d8343d0022f (patch)
tree53fb2ea61462510793ccbed088b7f492f425e78b /thread_sync.c
parent09b422505ca981207601cdb497cc72082431d7d4 (diff)
downloadruby-c37c67cef8f9aef160b198db4b100d8343d0022f.tar.gz
* thread_sync.c (queue_do_close): ignore multiple close to allow
multiple producers. https://bugs.ruby-lang.org/issues/10600#note-14 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_sync.c')
-rw-r--r--thread_sync.c30
1 files changed, 16 insertions, 14 deletions
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