Skip to content

Commit 3268679

Browse files
committed
Use dispatch instead of post to avoid thread hop
1 parent 68031ab commit 3268679

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

plugins/net_plugin/net_plugin.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -3949,7 +3949,7 @@ namespace eosio {
39493949
void connection::handle_message( const block_id_type& id, signed_block_ptr ptr ) {
39503950
// post to dispatcher strand so that we don't have multiple threads validating the block header
39513951
peer_dlog(this, "posting block ${n} to dispatcher strand", ("n", ptr->block_num()));
3952-
my_impl->dispatcher.strand.post([id, c{shared_from_this()}, ptr{std::move(ptr)}, cid=connection_id]() mutable {
3952+
my_impl->dispatcher.strand.dispatch([id, c{shared_from_this()}, ptr{std::move(ptr)}, cid=connection_id]() mutable {
39533953
if (app().is_quiting()) // large sync span can have many of these queued up, exit quickly
39543954
return;
39553955
controller& cc = my_impl->chain_plug->chain();
@@ -4028,11 +4028,9 @@ namespace eosio {
40284028
c->block_status_monitor_.accepted();
40294029

40304030
if (my_impl->chain_plug->chain().get_read_mode() == db_read_mode::IRREVERSIBLE) {
4031-
// non-irreversible notifies sync_manager when block is applied
4032-
my_impl->dispatcher.strand.post([sync_master = my_impl->sync_master.get(), bh=*obh]() {
4033-
const fc::microseconds age(fc::time_point::now() - bh.timestamp());
4034-
sync_master->sync_recv_block(connection_ptr{}, bh.id(), bh.block_num(), age);
4035-
});
4031+
// non-irreversible notifies sync_manager when block is applied, call on dispatcher strand
4032+
const fc::microseconds age(fc::time_point::now() - obh->timestamp());
4033+
my_impl->sync_master->sync_recv_block(connection_ptr{}, obh->id(), obh->block_num(), age);
40364034
}
40374035

40384036
if (fork_db_add_result == fork_db_add_t::appended_to_head || fork_db_add_result == fork_db_add_t::fork_switch) {

0 commit comments

Comments
 (0)