-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Fix TCP Connection data receive race condition #1578
Merged
Merged
Conversation
This file contains 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
Prior to this commit, when we `_accept`ed a new connection or completed a connection via `_event_notify` there was a race condition around reading data that the other party sent to us. This existed because we didn't check to see if any data was waiting on the socket for us already and instead only subscribed to ASIO events for new read notifications. If the other party sent us data after we signed up for ASIO events, we would successfully receive notification and read the data. However, if the other party sent us data before we signed up for ASIO events, we would not read the data already on the socket and would wait for an ASIO event telling us that we have data to read. This commit fixes this race condition by ensuring that we try to read from the socket whenever we `_accept` or complete a connection via `_event_notify` prior to signing up for ASIO events. This ensures we will not accidentally ignore any data that may already be on the socket by the time we're ready to handle the connection.
I forgot to mention that this change makes the |
The one failure in the CI matrix was a Travis blip, and unrelated to these changes. I'm merging. |
jemc
added
the
changelog - fixed
Automatically add "Fixed" CHANGELOG entry on merge
label
Feb 13, 2017
ponylang-main
added a commit
that referenced
this pull request
Feb 13, 2017
dipinhora
added a commit
to WallarooLabs/wally
that referenced
this pull request
Sep 28, 2017
Backport ponylang/ponyc#1578 and ponylang/ponyc#1626 to net actors because the help resolve edge cases around the networking code with direct impacts to the stability of the network tests.
nisanharamati
pushed a commit
to WallarooLabs/wally
that referenced
this pull request
Sep 29, 2017
Backport ponylang/ponyc#1578 and ponylang/ponyc#1626 to net actors because the help resolve edge cases around the networking code with direct impacts to the stability of the network tests.
dipinhora
added a commit
to WallarooLabs/wally
that referenced
this pull request
Oct 5, 2017
Backport ponylang/ponyc#1578 and ponylang/ponyc#1626 to net actors because the help resolve edge cases around the networking code with direct impacts to the stability of the network tests.
JONBRWN
pushed a commit
to WallarooLabs/wally
that referenced
this pull request
Oct 12, 2017
Backport ponylang/ponyc#1578 and ponylang/ponyc#1626 to net actors because the help resolve edge cases around the networking code with direct impacts to the stability of the network tests.
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.
Prior to this commit, when we
_accept
ed a new connectionor completed a connection via
_event_notify
there was a racecondition around reading data that the other party sent to us.
This existed because we didn't check to see if any data was
waiting on the socket for us already and instead only subscribed
to ASIO events for new read notifications. If the other party sent
us data after we signed up for ASIO events, we would successfully
receive notification and read the data. However, if the other
party sent us data before we signed up for ASIO events, we would
not read the data already on the socket and would wait for an ASIO
event telling us that we have data to read.
This commit fixes this race condition by ensuring that we try to
read from the socket whenever we
_accept
or complete a connectionvia
_event_notify
prior to signing up for ASIO events. Thisensures we will not accidentally ignore any data that may already
be on the socket by the time we're ready to handle the connection.