aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee/include')
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h3
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl8
-rw-r--r--contrib/epee/include/net/net_helper.h7
3 files changed, 13 insertions, 5 deletions
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index d0eabbba5..374a28a2e 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -93,11 +93,12 @@ namespace net_utils
struct shared_state : connection_basic_shared_state
{
shared_state()
- : connection_basic_shared_state(), pfilter(nullptr), config()
+ : connection_basic_shared_state(), pfilter(nullptr), config(), stop_signal_sent(false)
{}
i_connection_filter* pfilter;
typename t_protocol_handler::config_type config;
+ bool stop_signal_sent;
};
/// Construct a connection with the given io_service.
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 14fbec5d9..821594355 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -762,7 +762,11 @@ PRAGMA_WARNING_DISABLE_VS(4355)
m_timer.cancel();
boost::system::error_code ignored_ec;
if (m_ssl_support == epee::net_utils::ssl_support_t::e_ssl_support_enabled)
- socket_.shutdown(ignored_ec);
+ {
+ const shared_state &state = static_cast<const shared_state&>(get_state());
+ if (!state.stop_signal_sent)
+ socket_.shutdown(ignored_ec);
+ }
socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);
if (!m_host.empty())
{
@@ -1130,6 +1134,8 @@ POP_WARNINGS
void boosted_tcp_server<t_protocol_handler>::send_stop_signal()
{
m_stop_signal_sent = true;
+ typename connection<t_protocol_handler>::shared_state *state = static_cast<typename connection<t_protocol_handler>::shared_state*>(m_state.get());
+ state->stop_signal_sent = true;
TRY_ENTRY();
connections_mutex.lock();
for (auto &c: connections_)
diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h
index e8fb40a0a..89cef8134 100644
--- a/contrib/epee/include/net/net_helper.h
+++ b/contrib/epee/include/net/net_helper.h
@@ -428,9 +428,10 @@ namespace net_utils
handler_obj hndlr(ec, bytes_transfered);
- char local_buff[10000] = {0};
+ static const size_t max_size = 16384;
+ buff.resize(max_size);
- async_read(local_buff, sizeof(local_buff), boost::asio::transfer_at_least(1), hndlr);
+ async_read(&buff[0], max_size, boost::asio::transfer_at_least(1), hndlr);
// Block until the asynchronous operation has completed.
while (ec == boost::asio::error::would_block && !boost::interprocess::ipcdetail::atomic_read32(&m_shutdowned))
@@ -463,7 +464,7 @@ namespace net_utils
return false;*/
m_bytes_received += bytes_transfered;
- buff.assign(local_buff, bytes_transfered);
+ buff.resize(bytes_transfered);
return true;
}