ruby-changes:39651
From: ko1 <ko1@a...>
Date: Tue, 1 Sep 2015 18:17:36 +0900 (JST)
Subject: [ruby-changes:39651] ko1:r51732 (trunk): * thread_sync.c (queue_do_close): ignore multiple close to allow
ko1 2015-09-01 18:17:28 +0900 (Tue, 01 Sep 2015) New Revision: 51732 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51732 Log: * thread_sync.c (queue_do_close): ignore multiple close to allow multiple producers. https://bugs.ruby-lang.org/issues/10600#note-14 Modified files: trunk/ChangeLog trunk/thread_sync.c Index: thread_sync.c =================================================================== --- thread_sync.c (revision 51731) +++ thread_sync.c (revision 51732) @@ -619,23 +619,23 @@ queue_do_close(VALUE self, int argc, VAL https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L619 { VALUE exception = Qfalse; - if (queue_closed_p(self)) raise_closed_queue_error(self); - - rb_scan_args(argc, argv, "01", &exception); - FL_SET(self, QUEUE_CLOSED); - - 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 (is_szq && szqueue_num_waiting_producer(self) > 0) { - VALUE waiters = GET_SZQUEUE_WAITERS(self); - wakeup_all_threads(waiters); + if (!queue_closed_p(self)) { + rb_scan_args(argc, argv, "01", &exception); + FL_SET(self, QUEUE_CLOSED); + + 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 (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) https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L705 * * - +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 Index: ChangeLog =================================================================== --- ChangeLog (revision 51731) +++ ChangeLog (revision 51732) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 1 18:16:32 2015 Koichi Sasada <ko1@a...> + + * 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@a...> * thread_tools.c: rename thread_tools.c to thread_sync.c. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/