From ffa9fdaa9e57d6c865cfe442491da470e5b73cb6 Mon Sep 17 00:00:00 2001 From: kaidiren Date: Tue, 15 May 2018 16:41:48 +0800 Subject: [PATCH 1/3] fix typo --- contracts/eosiolib/privileged.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/eosiolib/privileged.h b/contracts/eosiolib/privileged.h index bffdbf00c91..b18dd08cb4b 100644 --- a/contracts/eosiolib/privileged.h +++ b/contracts/eosiolib/privileged.h @@ -26,7 +26,7 @@ extern "C" { void set_privileged( account_name account, bool is_priv ); - void set_blockchain_parameters_packed(char* data, uint32_t datalen); + void set_blockchain_parameters_packed(char* data, uint32_t datalen); /** * Retrieve the blolckchain parameters From eb5911b4ef44be1e97867ca3de20006d9dbce4ec Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 15 May 2018 08:31:00 -0500 Subject: [PATCH 2/3] Ensure only one async_write at a time --- plugins/net_plugin/net_plugin.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index e0959508294..50e4ad07932 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -453,20 +453,21 @@ namespace eosio { }; deque write_queue; deque out_queue; + bool queued_write = false; fc::sha256 node_id; handshake_message last_handshake_recv; handshake_message last_handshake_sent; - int16_t sent_handshake_count; - bool connecting; - bool syncing; - uint16_t protocol_version; + int16_t sent_handshake_count = 0; + bool connecting = false; + bool syncing = false; + uint16_t protocol_version = 0; string peer_addr; unique_ptr response_expected; optional pending_fetch; - go_away_reason no_retry; + go_away_reason no_retry = no_reason; block_id_type fork_head; - uint32_t fork_head_num; + uint32_t fork_head_num = 0; optional last_req; connection_status get_status()const { @@ -947,12 +948,12 @@ namespace eosio { bool trigger_send, std::function callback) { write_queue.push_back({buff, callback}); - if(write_queue.size() == 1 && trigger_send) + if(!queued_write && trigger_send) do_queue_write(); } void connection::do_queue_write() { - if(write_queue.empty()) + if(write_queue.empty() || queued_write) return; connection_wptr c(shared_from_this()); if(!socket->is_open()) { @@ -967,6 +968,7 @@ namespace eosio { out_queue.push_back(m); write_queue.pop_front(); } + queued_write = true; boost::asio::async_write(*socket, bufs, [c](boost::system::error_code ec, std::size_t w) { try { auto conn = c.lock(); @@ -986,12 +988,14 @@ namespace eosio { ilog("connection closure detected on write to ${p}",("p",pname)); } my_impl->close(conn); + conn->queued_write = false; return; } while (conn->out_queue.size() > 0) { conn->out_queue.pop_front(); } conn->enqueue_sync_block(); + conn->queued_write = false; conn->do_queue_write(); } catch(const std::exception &ex) { From d6949a6af823529125adb0aab38ce3bc80f905e9 Mon Sep 17 00:00:00 2001 From: Phil Mesnier Date: Tue, 15 May 2018 08:56:51 -0500 Subject: [PATCH 3/3] clean up the queued_write/out_queue.empty business --- plugins/net_plugin/net_plugin.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 50e4ad07932..c1889960928 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -453,8 +453,6 @@ namespace eosio { }; deque write_queue; deque out_queue; - bool queued_write = false; - fc::sha256 node_id; handshake_message last_handshake_recv; handshake_message last_handshake_sent; @@ -948,12 +946,12 @@ namespace eosio { bool trigger_send, std::function callback) { write_queue.push_back({buff, callback}); - if(!queued_write && trigger_send) + if(out_queue.empty() && trigger_send) do_queue_write(); } void connection::do_queue_write() { - if(write_queue.empty() || queued_write) + if(write_queue.empty() || !out_queue.empty()) return; connection_wptr c(shared_from_this()); if(!socket->is_open()) { @@ -968,7 +966,6 @@ namespace eosio { out_queue.push_back(m); write_queue.pop_front(); } - queued_write = true; boost::asio::async_write(*socket, bufs, [c](boost::system::error_code ec, std::size_t w) { try { auto conn = c.lock(); @@ -988,14 +985,12 @@ namespace eosio { ilog("connection closure detected on write to ${p}",("p",pname)); } my_impl->close(conn); - conn->queued_write = false; return; } while (conn->out_queue.size() > 0) { conn->out_queue.pop_front(); } conn->enqueue_sync_block(); - conn->queued_write = false; conn->do_queue_write(); } catch(const std::exception &ex) {