Add ProxyClientBase destroy_connection option #7
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.
Give ProxyClientBase class the ability to delete the Connection object in its destructor. This avoids the need for separate
ShutdownLoop
close hook in bitcoin/bitcoin#10102.This exposed a race condition which required adding a TaskSet member to Connection objects to fix. With the previous ShutdownLoop approach, the client capability handle would be freed in the event loop thread, then there would be a switch back to the client thread, then there would be another switch back to the event loop thread to free the connection, most likely after the event loop thread had a chance to process new events. With the new approach, the client capability handle and Connection object are destroyed back to back in the event loop thread, causing the onDisconnect handler to fire when it previously didn't, after the Connection object had already been destroyed, and resulting in a double deletion of the Connection pointer. The race is fixed here by using separate kj::TaskSet objects for each connection, so onDisconnect events are now cancelled as Connection objects are destroyed.