Repository navigation
Prevent concurrent close from reopening a closed transport - #633
Merged
Merged
Conversation
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.
A concurrent
WebSocketServer::stop()and peer shutdown can letWebSocketTransport::close()act on a stale OPEN state. After the connection thread finishes CLOSED and clears its message callback, the close caller moves the transport back to CLOSING. A second close notification then calls the cleared callback and throwsstd::bad_function_call.Recheck the state and perform the initial close metadata update and CLOSING transition under
_setReadyStateMutex. Preserve the fast path and poll interrupt for an ongoing/completed close: callbacks run under that mutex and may request close again. Sending the frame and waking the socket remain outside the state lock. C++11 compatibility and public APIs are unchanged.Add regressions that pause close initiation while shutdown or another close caller runs, and verify callback reentry. They check that CLOSED is never reopened, the first close request is preserved, only one Close frame is sent, and clearing the callback after shutdown is safe.
Validation:
std::bad_function_call; the reentry test passes.autobahnlabel enables the full suite in CI.git diff --checkpass.Closes #632.