Avoid creating a Thread for shutting down a DRbServer
* lib/drb/drb.rb: avoid creating a Thread and call the shutdown logic directly. Do not try to kill or join the current Thread. Thread.new { stop_service } caused "can't alloc thread (ThreadError)", which is shown with Thread.report_on_exception = true. [Bug #14171] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a3c024df0
commit
ca1c3d41fa
@ -1466,12 +1466,7 @@ module DRb
|
|||||||
if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
|
if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
|
||||||
Thread.current['DRb']['stop_service'] = true
|
Thread.current['DRb']['stop_service'] = true
|
||||||
else
|
else
|
||||||
if @protocol.respond_to? :shutdown
|
shutdown
|
||||||
@protocol.shutdown
|
|
||||||
else
|
|
||||||
[@thread, *@grp.list].each {|thread| thread.kill} # xxx: Thread#kill
|
|
||||||
end
|
|
||||||
@thread.join
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1490,6 +1485,18 @@ module DRb
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def shutdown
|
||||||
|
current = Thread.current
|
||||||
|
if @protocol.respond_to? :shutdown
|
||||||
|
@protocol.shutdown
|
||||||
|
else
|
||||||
|
[@thread, *@grp.list].each { |thread|
|
||||||
|
thread.kill unless thread == current # xxx: Thread#kill
|
||||||
|
}
|
||||||
|
end
|
||||||
|
@thread.join unless @thread == current
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Starts the DRb main loop in a new thread.
|
# Starts the DRb main loop in a new thread.
|
||||||
|
|
||||||
@ -1671,9 +1678,7 @@ module DRb
|
|||||||
error_print(e) if verbose
|
error_print(e) if verbose
|
||||||
ensure
|
ensure
|
||||||
client.close unless succ
|
client.close unless succ
|
||||||
if Thread.current['DRb']['stop_service']
|
shutdown if Thread.current['DRb']['stop_service']
|
||||||
Thread.new { stop_service }
|
|
||||||
end
|
|
||||||
break unless succ
|
break unless succ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user