Ignore client connection closing - simpler challenge response error handling #18
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.
There were significant oversights in the pull request #17.
While this code provided a great way of determining if the client indeed killed their session, there was a significant issue that arose, where this goroutine would read the first byte from the connection, causing any other readers which relied on this byte to effectively break themselves.
This code has been greatly simplified to, on the challenge responder side, simply check to see if we are receiving data from the channel (the channel closes, returning nil bytes). This was previously assuming any data obtained from the channel was in fact a byte array, which was false.
This code also resolves another bug, in which there was a goroutine reading from a channel from which the main thread was reading. While this code went unnoticed for a while, it was the cause of earlier panic issues (which were later obscured by concurrency bug fixes). The main channel always wins the race condition; but if it were to lose, this would result in a deadlock. The code has been simplified to have a channel created on the main thread, which the goroutine responds to either the timer expires or there is a message received from the Challenge Accepted channel (which other goroutines write to).