diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index dc836d578..34bc91070 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -106,7 +106,7 @@ public: template int invoke_async(int command, message_writer in_msg, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED); - int send(epee::byte_slice message, const boost::uuids::uuid& connection_id); + bool send(epee::byte_slice message, const boost::uuids::uuid& connection_id); bool close(boost::uuids::uuid connection_id, const bool wait_for_shutdown); bool update_connection_context(const t_connection_context& contxt); bool request_callback(boost::uuids::uuid connection_id); @@ -743,8 +743,8 @@ public: `message_writer::finalize_notify`. See additional instructions for `make_fragmented_notify`. - \return 1 on success */ - int send(byte_slice message) + \return true on success */ + bool send(byte_slice message) { const misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler( boost::bind(&async_protocol_handler::finish_outer_call, this) @@ -753,9 +753,9 @@ public: if (!send_message(std::move(message))) { LOG_ERROR_CC(m_connection_context, "Failed to send message, dropping it"); - return -1; + return false; } - return 1; + return true; } //------------------------------------------------------------------------------------------ boost::uuids::uuid get_connection_id() {return m_connection_context.m_connection_id;} @@ -935,11 +935,11 @@ void async_protocol_handler_config::set_handler(levin_comm } //------------------------------------------------------------------------------------------ template -int async_protocol_handler_config::send(byte_slice message, const boost::uuids::uuid& connection_id) +bool async_protocol_handler_config::send(byte_slice message, const boost::uuids::uuid& connection_id) { async_protocol_handler* aph; int r = find_and_lock_connection(connection_id, aph); - return LEVIN_OK == r ? aph->send(std::move(message)) : 0; + return LEVIN_OK == r ? aph->send(std::move(message)) : false; } //------------------------------------------------------------------------------------------ template diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h index 3998fa49c..6697fe69c 100644 --- a/contrib/epee/include/storages/levin_abstract_invoke2.h +++ b/contrib/epee/include/storages/levin_abstract_invoke2.h @@ -138,10 +138,10 @@ namespace epee levin::message_writer to_send; stg.store_to_binary(to_send.buffer); - int res = transport.send(to_send.finalize_notify(command), conn_id); - if(res <=0 ) + bool res = transport.send(to_send.finalize_notify(command), conn_id); + if(!res) { - MERROR("Failed to notify command " << command << " return code " << res); + MERROR("Failed to notify command " << command); return false; } return true; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index ee69ef38f..d124d2c30 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -2397,8 +2397,8 @@ namespace nodetool return false; network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone()); - int res = zone.m_net_server.get_config_object().send(message.finalize_notify(command), context.m_connection_id); - return res > 0; + bool res = zone.m_net_server.get_config_object().send(message.finalize_notify(command), context.m_connection_id); + return res; } //----------------------------------------------------------------------------------- template diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp index 1a734181b..5ff745bd1 100644 --- a/tests/unit_tests/levin.cpp +++ b/tests/unit_tests/levin.cpp @@ -2445,7 +2445,7 @@ TEST_F(levin_notify, command_max_bytes) bytes = dest.finalize_notify(ping_command); } - EXPECT_EQ(1, get_connections().send(bytes.clone(), contexts_.front().get_id())); + EXPECT_TRUE(get_connections().send(bytes.clone(), contexts_.front().get_id())); EXPECT_EQ(1u, contexts_.front().process_send_queue(true)); EXPECT_EQ(1u, receiver_.notified_size()); @@ -2461,7 +2461,7 @@ TEST_F(levin_notify, command_max_bytes) bytes = dest.finalize_notify(ping_command); } - EXPECT_EQ(1, get_connections().send(std::move(bytes), contexts_.front().get_id())); + EXPECT_TRUE(get_connections().send(std::move(bytes), contexts_.front().get_id())); EXPECT_EQ(1u, contexts_.front().process_send_queue(false)); EXPECT_EQ(0u, receiver_.notified_size()); }