From e5897e752f706178d53e9296a723c6fef518cd60 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 19 Sep 2019 07:24:37 +0200 Subject: [PATCH 01/11] Prevent a connection from sending a message before it is fully initialized --- libraries/net/message_oriented_connection.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index de3cf0875b..d5c0958f1b 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -52,6 +52,7 @@ namespace graphene { namespace net { message_oriented_connection* _self; message_oriented_connection_delegate *_delegate; stcp_socket _sock; + fc::promise::ptr _ready_for_sending; fc::future _read_loop_done; uint64_t _bytes_received; uint64_t _bytes_sent; @@ -95,6 +96,7 @@ namespace graphene { namespace net { message_oriented_connection_delegate* delegate) : _self(self), _delegate(delegate), + _ready_for_sending(fc::promise::create()), _bytes_received(0), _bytes_sent(0), _send_message_in_progress(false) @@ -121,6 +123,7 @@ namespace graphene { namespace net { _sock.accept(); assert(!_read_loop_done.valid()); // check to be sure we never launch two read loops _read_loop_done = fc::async([=](){ read_loop(); }, "message read_loop"); + _ready_for_sending->set_value(); } void message_oriented_connection_impl::connect_to(const fc::ip::endpoint& remote_endpoint) @@ -129,6 +132,7 @@ namespace graphene { namespace net { _sock.connect_to(remote_endpoint); assert(!_read_loop_done.valid()); // check to be sure we never launch two read loops _read_loop_done = fc::async([=](){ read_loop(); }, "message read_loop"); + _ready_for_sending->set_value(); } void message_oriented_connection_impl::bind(const fc::ip::endpoint& local_endpoint) @@ -251,6 +255,7 @@ namespace graphene { namespace net { } ~verify_no_send_in_progress() { var = false; } } _verify_no_send_in_progress(_send_message_in_progress); + _ready_for_sending->wait(); try { @@ -301,6 +306,7 @@ namespace graphene { namespace net { { wlog( "Exception thrown while canceling message_oriented_connection's read_loop, ignoring" ); } + _ready_for_sending->set_exception( std::make_shared() ); } uint64_t message_oriented_connection_impl::get_total_bytes_sent() const From 82f1e236dd8f1b312404609271069affe3aef06d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 19 Sep 2019 07:25:09 +0200 Subject: [PATCH 02/11] Bump fc for yield-in-exception-handler fix --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 7a4758671f..2cc32d79ba 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 7a4758671ff3635a6493ea5a6206b570beda976a +Subproject commit 2cc32d79ba9422e1eed93c6ef540ca9db14dd9a9 From 639902033690408a881aebf40e462231efffce15 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 19 Sep 2019 16:06:17 +0200 Subject: [PATCH 03/11] Fixes wrt array-initialization --- libraries/net/include/graphene/net/stcp_socket.hpp | 2 -- libraries/protocol/address.cpp | 10 +++++----- .../protocol/include/graphene/protocol/pts_address.hpp | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libraries/net/include/graphene/net/stcp_socket.hpp b/libraries/net/include/graphene/net/stcp_socket.hpp index fb4bfbc72b..ff0ea337ed 100644 --- a/libraries/net/include/graphene/net/stcp_socket.hpp +++ b/libraries/net/include/graphene/net/stcp_socket.hpp @@ -26,8 +26,6 @@ #include #include -#include - namespace graphene { namespace net { /** diff --git a/libraries/protocol/address.cpp b/libraries/protocol/address.cpp index a826289a1e..06e1946d1b 100644 --- a/libraries/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -89,12 +89,12 @@ namespace graphene { namespace protocol { address::operator std::string()const { - std::array bin_addr; - static_assert( bin_addr.size() >= sizeof(addr) + 4, "address size mismatch" ); - memcpy( bin_addr.data(), addr.data(), sizeof(addr) ); + char bin_addr[24]; + static_assert( sizeof(bin_addr) >= sizeof(addr) + 4, "address size mismatch" ); + memcpy( bin_addr, addr.data(), sizeof(addr) ); auto checksum = fc::ripemd160::hash( addr.data(), sizeof(addr) ); - memcpy( bin_addr.data() + 20, (char*)&checksum._hash[0], 4 ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data(), bin_addr.size() ); + memcpy( bin_addr + sizeof(addr), (char*)&checksum._hash[0], 4 ); + return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr, sizeof(bin_addr) ); } } } // namespace graphene::protocol diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index 8a30a44bfa..0a6e4cccea 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -49,7 +49,7 @@ namespace graphene { namespace protocol { operator std::string()const; ///< converts to base58 + checksum - std::array addr; ///< binary representation of address + std::array addr{}; ///< binary representation of address, 0-initialized }; inline bool operator == ( const pts_address& a, const pts_address& b ) { return a.addr == b.addr; } From 7de9985338bfe2f8b42a6837f58904f2c3cf53b0 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 21 Sep 2019 10:12:06 +0200 Subject: [PATCH 04/11] Bump fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 2cc32d79ba..6d8d0307a2 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 2cc32d79ba9422e1eed93c6ef540ca9db14dd9a9 +Subproject commit 6d8d0307a2058665fea242bb425f9dc014cbeaa3 From 144e5c9facccb76b5bb97ded57e76500025194a0 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Mon, 28 Aug 2017 18:58:15 +0200 Subject: [PATCH 05/11] Fixes for most of valgrind errors related to unintialized values Including one additional debug code (related to read_loop MT access). --- .../net/include/graphene/net/message.hpp | 5 +++ .../include/graphene/net/peer_connection.hpp | 40 +++++++++---------- libraries/net/message_oriented_connection.cpp | 27 ++++++++++++- libraries/net/node.cpp | 15 +++++++ 4 files changed, 65 insertions(+), 22 deletions(-) diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index cfff380f9b..6d254b6120 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -44,6 +44,11 @@ namespace graphene { namespace net { { boost::endian::little_uint32_buf_t size; // number of bytes in message, capped at MAX_MESSAGE_SIZE boost::endian::little_uint32_buf_t msg_type; // every channel gets a 16 bit message type specifier + message_header() + { + size = 0; + msg_type = 0; + } }; typedef fc::uint160_t message_hash_type; diff --git a/libraries/net/include/graphene/net/peer_connection.hpp b/libraries/net/include/graphene/net/peer_connection.hpp index dd9d6eb774..892f5af58c 100644 --- a/libraries/net/include/graphene/net/peer_connection.hpp +++ b/libraries/net/include/graphene/net/peer_connection.hpp @@ -164,25 +164,25 @@ namespace graphene { namespace net }; - size_t _total_queued_messages_size; + size_t _total_queued_messages_size = 0; std::queue, std::list > > _queued_messages; fc::future _send_queued_messages_done; public: fc::time_point connection_initiation_time; fc::time_point connection_closed_time; fc::time_point connection_terminated_time; - peer_connection_direction direction; + peer_connection_direction direction = peer_connection_direction::unknown; //connection_state state; - firewalled_state is_firewalled; + firewalled_state is_firewalled = firewalled_state::unknown; fc::microseconds clock_offset; fc::microseconds round_trip_delay; - our_connection_state our_state; - bool they_have_requested_close; - their_connection_state their_state; - bool we_have_requested_close; + our_connection_state our_state = our_connection_state::disconnected; + bool they_have_requested_close = false; + their_connection_state their_state = their_connection_state::disconnected; + bool we_have_requested_close = false; - connection_negotiation_status negotiation_status; + connection_negotiation_status negotiation_status = connection_negotiation_status::disconnected; fc::oexception connection_closed_error; fc::time_point get_connection_time()const { return _message_connection.get_connection_time(); } @@ -197,7 +197,7 @@ namespace graphene { namespace net * from the user_data field of the hello, or if none is present it will be filled with a * copy of node_public_key */ node_id_t node_id; - uint32_t core_protocol_version; + uint32_t core_protocol_version = 0; std::string user_agent; fc::optional graphene_git_revision_sha; fc::optional graphene_git_revision_unix_timestamp; @@ -210,8 +210,8 @@ namespace graphene { namespace net // its hello message. For outbound, they record what we sent the peer // in our hello message fc::ip::address inbound_address; - uint16_t inbound_port; - uint16_t outbound_port; + uint16_t inbound_port = 0; + uint16_t outbound_port = 0; /// @} typedef std::unordered_map item_to_time_map_type; @@ -220,15 +220,15 @@ namespace graphene { namespace net /// @{ boost::container::deque ids_of_items_to_get; /// id of items in the blockchain that this peer has told us about std::set ids_of_items_being_processed; /// list of all items this peer has offered use that we've already handed to the client but the client hasn't finished processing - uint32_t number_of_unfetched_item_ids; /// number of items in the blockchain that follow ids_of_items_to_get but the peer hasn't yet told us their ids - bool peer_needs_sync_items_from_us; - bool we_need_sync_items_from_peer; + uint32_t number_of_unfetched_item_ids = 0; /// number of items in the blockchain that follow ids_of_items_to_get but the peer hasn't yet told us their ids + bool peer_needs_sync_items_from_us = false; + bool we_need_sync_items_from_peer = false; fc::optional, fc::time_point> > item_ids_requested_from_peer; /// we check this to detect a timed-out request and in busy() fc::time_point last_sync_item_received_time; /// the time we received the last sync item or the time we sent the last batch of sync item requests to this peer std::set sync_items_requested_from_peer; /// ids of blocks we've requested from this peer during sync. fetch from another peer if this peer disconnects item_hash_t last_block_delegate_has_seen; /// the hash of the last block this peer has told us about that the peer knows fc::time_point_sec last_block_time_delegate_has_seen; - bool inhibit_fetching_sync_blocks; + bool inhibit_fetching_sync_blocks = false; /// @} /// non-synchronization state data @@ -258,17 +258,17 @@ namespace graphene { namespace net // blockchain catch up fc::time_point transaction_fetching_inhibited_until; - uint32_t last_known_fork_block_number; + uint32_t last_known_fork_block_number = 0; fc::future accept_or_connect_task_done; - firewall_check_state_data *firewall_check_state; + firewall_check_state_data *firewall_check_state = nullptr; #ifndef NDEBUG private: - fc::thread* _thread; - unsigned _send_message_queue_tasks_running; // temporary debugging + fc::thread* _thread = nullptr; + unsigned _send_message_queue_tasks_running = 0; // temporary debugging #endif - bool _currently_handling_message; // true while we're in the middle of handling a message from the remote system + bool _currently_handling_message = false; // true while we're in the middle of handling a message from the remote system private: peer_connection(peer_connection_delegate* delegate); void destroy(); diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index d5c0958f1b..8f864ac25c 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -32,6 +32,8 @@ #include #include +#include + #ifdef DEFAULT_LOGGER # undef DEFAULT_LOGGER #endif @@ -62,7 +64,7 @@ namespace graphene { namespace net { fc::time_point _last_message_sent_time; bool _send_message_in_progress; - + std::atomic_bool readLoopInProgress; #ifndef NDEBUG fc::thread* _thread; #endif @@ -99,7 +101,8 @@ namespace graphene { namespace net { _ready_for_sending(fc::promise::create()), _bytes_received(0), _bytes_sent(0), - _send_message_in_progress(false) + _send_message_in_progress(false), + readLoopInProgress(false) #ifndef NDEBUG ,_thread(&fc::thread::current()) #endif @@ -141,6 +144,20 @@ namespace graphene { namespace net { _sock.bind(local_endpoint); } + class THelper final + { + std::atomic_bool* Flag; + public: + explicit THelper(std::atomic_bool* flag) : Flag(flag) + { + FC_ASSERT(*flag == false, "Only one thread at time can visit it"); + *flag = true; + } + ~THelper() + { + *Flag = false; + } + }; void message_oriented_connection_impl::read_loop() { @@ -149,6 +166,8 @@ namespace graphene { namespace net { const int LEFTOVER = BUFFER_SIZE - sizeof(message_header); static_assert(BUFFER_SIZE >= sizeof(message_header), "insufficient buffer"); + THelper helper(&this->readLoopInProgress); + _connected_time = fc::time_point::now(); fc::oexception exception_to_rethrow; @@ -265,8 +284,12 @@ namespace graphene { namespace net { //pad the message we send to a multiple of 16 bytes size_t size_with_padding = 16 * ((size_of_message_and_header + 15) / 16); std::unique_ptr padded_message(new char[size_with_padding]); + memcpy(padded_message.get(), (char*)&message_to_send, sizeof(message_header)); memcpy(padded_message.get() + sizeof(message_header), message_to_send.data.data(), message_to_send.size.value() ); + char* paddingSpace = padded_message.get() + sizeof(message_header) + message_to_send.size.value(); + size_t toClean = size_with_padding - size_of_message_and_header; + memset(paddingSpace, 0, toClean); _sock.write(padded_message.get(), size_with_padding); _sock.flush(); _bytes_sent += size_with_padding; diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 9a9b98386b..48b1fe9eaf 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -4965,18 +4965,33 @@ namespace graphene { namespace net { namespace detail { # define INVOKE_AND_COLLECT_STATISTICS(method_name, ...) \ try \ { \ +<<<<<<< HEAD std::shared_ptr statistics_collector = std::make_shared( \ #method_name, \ &_ ## method_name ## _execution_accumulator, \ &_ ## method_name ## _delay_before_accumulator, \ &_ ## method_name ## _delay_after_accumulator); \ +======= +>>>>>>> 0bda58f55... Fixes for most of valgrind errors related to unintialized values if (_thread->is_current()) \ { \ + call_statistics_collector statistics_collector(#method_name, \ + &_ ## method_name ## _execution_accumulator, \ + &_ ## method_name ## _delay_before_accumulator, \ + &_ ## method_name ## _delay_after_accumulator); \ call_statistics_collector::actual_execution_measurement_helper helper(statistics_collector); \ return _node_delegate->method_name(__VA_ARGS__); \ } \ else \ +<<<<<<< HEAD return _thread->async([&, statistics_collector](){ \ +======= + return _thread->async([&](){ \ + call_statistics_collector statistics_collector(#method_name, \ + &_ ## method_name ## _execution_accumulator, \ + &_ ## method_name ## _delay_before_accumulator, \ + &_ ## method_name ## _delay_after_accumulator); \ +>>>>>>> 0bda58f55... Fixes for most of valgrind errors related to unintialized values call_statistics_collector::actual_execution_measurement_helper helper(statistics_collector); \ return _node_delegate->method_name(__VA_ARGS__); \ }, "invoke " BOOST_STRINGIZE(method_name)).wait(); \ From 6c49bd457e3a63a2608bf6d2f054f6c2d5583fc1 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 22 Sep 2019 13:43:39 +0200 Subject: [PATCH 06/11] Fixed mismerge --- libraries/net/node.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 48b1fe9eaf..9a9b98386b 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -4965,33 +4965,18 @@ namespace graphene { namespace net { namespace detail { # define INVOKE_AND_COLLECT_STATISTICS(method_name, ...) \ try \ { \ -<<<<<<< HEAD std::shared_ptr statistics_collector = std::make_shared( \ #method_name, \ &_ ## method_name ## _execution_accumulator, \ &_ ## method_name ## _delay_before_accumulator, \ &_ ## method_name ## _delay_after_accumulator); \ -======= ->>>>>>> 0bda58f55... Fixes for most of valgrind errors related to unintialized values if (_thread->is_current()) \ { \ - call_statistics_collector statistics_collector(#method_name, \ - &_ ## method_name ## _execution_accumulator, \ - &_ ## method_name ## _delay_before_accumulator, \ - &_ ## method_name ## _delay_after_accumulator); \ call_statistics_collector::actual_execution_measurement_helper helper(statistics_collector); \ return _node_delegate->method_name(__VA_ARGS__); \ } \ else \ -<<<<<<< HEAD return _thread->async([&, statistics_collector](){ \ -======= - return _thread->async([&](){ \ - call_statistics_collector statistics_collector(#method_name, \ - &_ ## method_name ## _execution_accumulator, \ - &_ ## method_name ## _delay_before_accumulator, \ - &_ ## method_name ## _delay_after_accumulator); \ ->>>>>>> 0bda58f55... Fixes for most of valgrind errors related to unintialized values call_statistics_collector::actual_execution_measurement_helper helper(statistics_collector); \ return _node_delegate->method_name(__VA_ARGS__); \ }, "invoke " BOOST_STRINGIZE(method_name)).wait(); \ From 896bba428f530d0f976c2d35b35db12032ef75fa Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 22 Sep 2019 13:55:47 +0200 Subject: [PATCH 07/11] Adapt coding style --- libraries/net/message_oriented_connection.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index 8f864ac25c..77db2d4e6d 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -64,7 +64,7 @@ namespace graphene { namespace net { fc::time_point _last_message_sent_time; bool _send_message_in_progress; - std::atomic_bool readLoopInProgress; + std::atomic_bool _read_loop_in_progress; #ifndef NDEBUG fc::thread* _thread; #endif @@ -102,7 +102,7 @@ namespace graphene { namespace net { _bytes_received(0), _bytes_sent(0), _send_message_in_progress(false), - readLoopInProgress(false) + _read_loop_in_progress(false) #ifndef NDEBUG ,_thread(&fc::thread::current()) #endif @@ -144,18 +144,18 @@ namespace graphene { namespace net { _sock.bind(local_endpoint); } - class THelper final + class no_parallel_execution_guard final { - std::atomic_bool* Flag; + std::atomic_bool* _flag; public: - explicit THelper(std::atomic_bool* flag) : Flag(flag) + explicit no_parallel_execution_guard(std::atomic_bool* flag) : _flag(flag) { - FC_ASSERT(*flag == false, "Only one thread at time can visit it"); - *flag = true; + FC_ASSERT(*flag == false, "Only one thread at time can visit it"); + *flag = true; } - ~THelper() + ~no_parallel_execution_guard() { - *Flag = false; + *_flag = false; } }; @@ -166,7 +166,7 @@ namespace graphene { namespace net { const int LEFTOVER = BUFFER_SIZE - sizeof(message_header); static_assert(BUFFER_SIZE >= sizeof(message_header), "insufficient buffer"); - THelper helper(&this->readLoopInProgress); + no_parallel_execution_guard guard( &_read_loop_in_progress ); _connected_time = fc::time_point::now(); From a226e0b80ba52f990b1b7ac43f7c95e25d7672c9 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 22 Sep 2019 13:57:43 +0200 Subject: [PATCH 08/11] Avoid race-condition in no_parallel_execution_guard --- libraries/net/message_oriented_connection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index 77db2d4e6d..1505a79da7 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -150,8 +150,8 @@ namespace graphene { namespace net { public: explicit no_parallel_execution_guard(std::atomic_bool* flag) : _flag(flag) { - FC_ASSERT(*flag == false, "Only one thread at time can visit it"); - *flag = true; + bool expected = false; + FC_ASSERT( flag->compare_exchange_strong( expected, true ), "Only one thread at time can visit it"); } ~no_parallel_execution_guard() { From eb9dc04c620a0827f11b547d7a37907ba8a00f68 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 23 Sep 2019 07:56:56 +0200 Subject: [PATCH 09/11] Replace verify_no_send_in_progress with no_parallel_execution_guard --- libraries/net/message_oriented_connection.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index 1505a79da7..ec752dc4ac 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -63,7 +63,7 @@ namespace graphene { namespace net { fc::time_point _last_message_received_time; fc::time_point _last_message_sent_time; - bool _send_message_in_progress; + std::atomic_bool _send_message_in_progress; std::atomic_bool _read_loop_in_progress; #ifndef NDEBUG fc::thread* _thread; @@ -263,17 +263,7 @@ namespace graphene { namespace net { } send_message_scope_logger(remote_endpoint); #endif #endif - struct verify_no_send_in_progress { - bool& var; - verify_no_send_in_progress(bool& var) : var(var) - { - if (var) - elog("Error: two tasks are calling message_oriented_connection::send_message() at the same time"); - assert(!var); - var = true; - } - ~verify_no_send_in_progress() { var = false; } - } _verify_no_send_in_progress(_send_message_in_progress); + no_parallel_execution_guard guard( &_send_message_in_progress ); _ready_for_sending->wait(); try From 97da3f09a1e4ad52fbd8209f1ca4de4e0877a1f3 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 23 Sep 2019 07:58:06 +0200 Subject: [PATCH 10/11] Fixup style --- libraries/net/message_oriented_connection.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index ec752dc4ac..b62651fa76 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -277,9 +277,8 @@ namespace graphene { namespace net { memcpy(padded_message.get(), (char*)&message_to_send, sizeof(message_header)); memcpy(padded_message.get() + sizeof(message_header), message_to_send.data.data(), message_to_send.size.value() ); - char* paddingSpace = padded_message.get() + sizeof(message_header) + message_to_send.size.value(); - size_t toClean = size_with_padding - size_of_message_and_header; - memset(paddingSpace, 0, toClean); + char* padding_space = padded_message.get() + sizeof(message_header) + message_to_send.size.value(); + memset(padding_space, 0, size_with_padding - size_of_message_and_header); _sock.write(padded_message.get(), size_with_padding); _sock.flush(); _bytes_sent += size_with_padding; From 91c4b4e5cc051017ab363438c8ef3d6b8d02c738 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 23 Sep 2019 08:00:54 +0200 Subject: [PATCH 11/11] Make _currently_handling_message always private --- libraries/net/include/graphene/net/peer_connection.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/net/include/graphene/net/peer_connection.hpp b/libraries/net/include/graphene/net/peer_connection.hpp index 892f5af58c..a00e43dcbf 100644 --- a/libraries/net/include/graphene/net/peer_connection.hpp +++ b/libraries/net/include/graphene/net/peer_connection.hpp @@ -263,13 +263,12 @@ namespace graphene { namespace net fc::future accept_or_connect_task_done; firewall_check_state_data *firewall_check_state = nullptr; -#ifndef NDEBUG private: +#ifndef NDEBUG fc::thread* _thread = nullptr; unsigned _send_message_queue_tasks_running = 0; // temporary debugging #endif bool _currently_handling_message = false; // true while we're in the middle of handling a message from the remote system - private: peer_connection(peer_connection_delegate* delegate); void destroy(); public: