Repository navigation
Conversation
Several threads calling stop and shutdown together must not raise.
stop writes the pipe while shutdown and the server thread close it. A write that lands after close uses a dead file descriptor. The write and both closes now share one mutex, and a close runs only once.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #102.
stopwrites one byte to the shutdown pipe.shutdownand the server thread both close that pipe, from different threads. The closed? check and the write were not atomic, sowrite_nonblockcan run aftercloseand hitEBADF, or write a recycled descriptor. CRuby’sIO#closehides this most of the time; TruffleRuby and JRuby do not.The write and both closes now take
@shutdown_pipe_mutex. The close runs only while@shutdown_pipeis still that pipe, and a second close seesclosed?. A server that is started again does not have its new pipe closed by the previous cleanup.ruby -Ilib:test/lib -rhelper test/webrick/test_server.rb: 8 tests, 23 assertions, 0 failures. Thirty threads callingstopandshutdowntogether raise nothing.