Skip to content

Commit 55657a9

Browse files
committed
Do not stop the EventMachine's reactor when Thin was started
inside a running loop. Eg.: EM.run server = Thin::Server.start(3000) # This will NOT call EM.stop because Thin was started inside a # running loop. server.stop end
1 parent 0c7fa38 commit 55657a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/thin/backends/base.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def initialize
5353
@no_epoll = false
5454
@ssl = nil
5555
@threaded = nil
56+
@started_reactor = false
5657
end
5758

5859
# Start the backend and connect it.
@@ -67,6 +68,7 @@ def start
6768
if EventMachine.reactor_running?
6869
starter.call
6970
else
71+
@started_reactor = true
7072
EventMachine.run(&starter)
7173
end
7274
end
@@ -88,7 +90,7 @@ def stop!
8890
@running = false
8991
@stopping = false
9092

91-
EventMachine.stop if EventMachine.reactor_running?
93+
EventMachine.stop if @started_reactor && EventMachine.reactor_running?
9294
@connections.each_value { |connection| connection.close_connection }
9395
close
9496
end

0 commit comments

Comments
 (0)