ruby-changes:53995
From: kazu <ko1@a...>
Date: Wed, 5 Dec 2018 18:07:58 +0900 (JST)
Subject: [ruby-changes:53995] kazu:r66215 (trunk): lib/monitor.rb: prevent to initialize MonitorMixin twice
kazu 2018-12-05 18:07:54 +0900 (Wed, 05 Dec 2018) New Revision: 66215 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66215 Log: lib/monitor.rb: prevent to initialize MonitorMixin twice and allow to initialize again when obj.dup. Suggested by Benoit Daloze. [ruby-core:88504] [Feature #15000] Modified files: trunk/lib/monitor.rb Index: lib/monitor.rb =================================================================== --- lib/monitor.rb (revision 66214) +++ lib/monitor.rb (revision 66215) @@ -255,9 +255,13 @@ module MonitorMixin https://github.com/ruby/ruby/blob/trunk/lib/monitor.rb#L255 # Initializes the MonitorMixin after being included in a class or when an # object has been extended with the MonitorMixin def mon_initialize + if defined?(@mon_mutex) && @mon_mutex_owner_object_id == object_id + raise ThreadError, "already initialized" + end + @mon_mutex = Thread::Mutex.new + @mon_mutex_owner_object_id = object_id @mon_owner = nil @mon_count = 0 - @mon_mutex = Thread::Mutex.new end def mon_check_owner -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/