Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mri gli pipe bug #1347

Merged
merged 3 commits into from Jun 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 15 additions & 16 deletions lib/puma/server.rb
Expand Up @@ -892,35 +892,34 @@ def graceful_shutdown
end
end

# Stops the acceptor thread and then causes the worker threads to finish
# off the request queue before finally exiting.
#
def stop(sync=false)
def notify_safely(message)
begin
@notify << STOP_COMMAND
@notify << message
rescue IOError
# The server, in another thread, is shutting down
rescue RuntimeError => e
# The server, in another thread, has been shut down during the system call
# https://github.com/puma/puma/pull/1206
raise e unless e.message.include?('IOError')
end
end
private :notify_safely

# Stops the acceptor thread and then causes the worker threads to finish
# off the request queue before finally exiting.

def stop(sync=false)
notify_safely(STOP_COMMAND)
@thread.join if @thread && sync
end

def halt(sync=false)
begin
@notify << HALT_COMMAND
rescue IOError
# The server, in another thread, is shutting down
end

notify_safely(HALT_COMMAND)
@thread.join if @thread && sync
end

def begin_restart
begin
@notify << RESTART_COMMAND
rescue IOError
# The server, in another thread, is shutting down
end
notify_safely(RESTART_COMMAND)
end

def fast_write(io, str)
Expand Down