Avoid calling handleClientConnection if initializeClientConnection fails #221
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.
Description
This is a follow-on to #219, which split out the socket accept from the protocol initialization for SSL connections, in order to perform the latter on a separate thread.
In the case where the socket initialization fails, such as with an SSL handshake error, following #219 we would log the error but then attempt to handle the client connection anyway, resulting in unnecessary work and further errors.
This PR moves the
do
/catch
logic forinitializeClientConnection
so that we only try to callhandleClientConnection
if the former was successful.I also updated the log messages to document the source of a connection when it fails initialization.
Motivation and Context
Avoids unnecessary attempts to handle a connection for which the SSL initialization has failed, and reporting of further errors as a consequence.
How Has This Been Tested?
I have run the Kitura-net tests and they are passing. Note that there is an intermittent test failure exposed by the test intrduced in #219 - which intentionally generates a bad connection to an SSL listener - which will be resolved by Kitura/BlueSSLService#42.
Checklist: