net_helper: fix massive slowdown after SSL support

This commit is contained in:
moneromooo-monero 2017-10-20 17:27:15 +01:00
parent 8d511f3c24
commit 969b5a2ae3
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 5 additions and 5 deletions

View File

@ -382,7 +382,7 @@ namespace net_utils
char local_buff[10000] = {0};
async_read(local_buff, boost::asio::transfer_at_least(1), hndlr);
async_read(local_buff, sizeof(local_buff), 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 +463,7 @@ namespace net_utils
handler_obj hndlr(ec, bytes_transfered);
async_read((char*)buff.data(), boost::asio::transfer_at_least(buff.size()), hndlr);
async_read((char*)buff.data(), buff.size(), boost::asio::transfer_at_least(buff.size()), hndlr);
// Block until the asynchronous operation has completed.
while (ec == boost::asio::error::would_block && !boost::interprocess::ipcdetail::atomic_read32(&m_shutdowned))
@ -599,12 +599,12 @@ namespace net_utils
boost::asio::async_write(m_ssl_socket.next_layer(), boost::asio::buffer(data, sz), boost::lambda::var(ec) = boost::lambda::_1);
}
void async_read(char* buff, boost::asio::detail::transfer_at_least_t transfer_at_least, handler_obj& hndlr)
void async_read(char* buff, size_t sz, boost::asio::detail::transfer_at_least_t transfer_at_least, handler_obj& hndlr)
{
if(!m_ssl)
boost::asio::async_read(m_ssl_socket.next_layer(), boost::asio::buffer(buff, sizeof(buff)), transfer_at_least, hndlr);
boost::asio::async_read(m_ssl_socket.next_layer(), boost::asio::buffer(buff, sz), transfer_at_least, hndlr);
else
boost::asio::async_read(m_ssl_socket, boost::asio::buffer(buff, sizeof(buff)), transfer_at_least, hndlr);
boost::asio::async_read(m_ssl_socket, boost::asio::buffer(buff, sz), transfer_at_least, hndlr);
}