Skip to content
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

[4.0] Correctly handle close while syncing #1171

Merged
merged 2 commits into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,8 @@ namespace eosio {
} );
sync_known_lib_num = highest_lib_num;

// if closing the connection we are currently syncing from, then reset our last requested and next expected.
if( c == sync_source ) {
// if closing the connection we are currently syncing from or not syncing, then reset our last requested and next expected.
if( !sync_source || c == sync_source ) {
reset_last_requested_num(g);
// if starting to sync need to always start from lib as we might be on our own fork
uint32_t lib_num = my_impl->get_chain_lib_num();
Expand Down Expand Up @@ -3253,18 +3253,6 @@ namespace eosio {
// use c in this method instead of this to highlight that all methods called on c-> must be thread safe
connection_ptr c = shared_from_this();

// if we have closed connection then stop processing
if( !c->socket_is_open() ) {
if( bsp ) {
// valid bsp means add_peer_block already called, need to remove it since we are not going to process the block
// call on dispatch strand to serialize with the add_peer_block calls
my_impl->dispatcher->strand.post( [blk_id]() {
my_impl->dispatcher->rm_block( blk_id );
} );
}
return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this was already removed on main as an optimization. See #1045.

try {
if( cc.fetch_block_by_id(blk_id) ) {
c->strand.post( [sync_master = my_impl->sync_master.get(),
Expand Down