fix: connection close should stay outside the poll loop #2308
+4
−2
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.
Really don't like the macro! I just realize that
try_break
macro will break the poll loop, that means in case of error, we send error message toerror_tx
, and rely onpeer::check_connection
to get this error and then callstop_with_connection
, and then send a message inclose_channel
, but at this time, unfortunately theclose_channel
(i.e.close_rx
inconn::poll
) will never be read, because poll thread already exit!So, let's move that
conn.shutdown
to the outside of poll loop, to make sure an error connection is cleaned.Another modification in this PR for peer is a small improvement to not cache the duplicated hash (for received header/block/compact_block/tx) from a peer.