aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/asio/asio_async_write_op.h
diff options
context:
space:
mode:
authorTim Oesterreich <[email protected]>2019-03-06 16:34:07 +0100
committerHannes Rantzsch <[email protected]>2019-04-16 10:48:13 +0200
commitb1acdbfe4f6ed49691dc16e74bd8906bedf3c625 (patch)
treeb9ce31b3c41723e28bd02847076f3495e712e4a0 /src/lib/tls/asio/asio_async_write_op.h
parente2ed1d7af6302d2d4f5da9460be85e2f99f7b6d0 (diff)
async ops will now call operator() from their constructor -> initiating functions do not have to call async_read/write anymore
Diffstat (limited to 'src/lib/tls/asio/asio_async_write_op.h')
-rw-r--r--src/lib/tls/asio/asio_async_write_op.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/tls/asio/asio_async_write_op.h b/src/lib/tls/asio/asio_async_write_op.h
index e8cda3e76..ac1d96857 100644
--- a/src/lib/tls/asio/asio_async_write_op.h
+++ b/src/lib/tls/asio/asio_async_write_op.h
@@ -39,31 +39,33 @@ struct AsyncWriteOperation : public AsyncBase<Handler, typename Stream::executor
, m_stream(stream)
, m_core(core)
, m_plainBytesTransferred(plainBytesTransferred)
- , m_ec(ec)
{
+ this->operator()(ec, std::size_t(0), false);
}
AsyncWriteOperation(AsyncWriteOperation&&) = default;
- using typename AsyncBase<Handler, typename Stream::executor_type, Allocator>::allocator_type;
- using typename AsyncBase<Handler, typename Stream::executor_type, Allocator>::executor_type;
-
void operator()(boost::system::error_code ec, std::size_t bytes_transferred, bool isContinuation = true)
{
reenter(this)
{
m_core.consumeSendBuffer(bytes_transferred);
- if(ec) { m_ec = ec; }
+ if(m_core.hasDataToSend() && !ec){
+ boost::asio::async_write(m_stream.next_layer(), m_core.sendBuffer(), std::move(*this));
+ return;
+ }
if(!isContinuation)
{
+ m_ec = ec;
yield m_stream.next_layer().async_write_some(boost::asio::const_buffer(), std::move(*this));
+ ec = m_ec;
}
// the size of the sent TLS record can differ from the size of the payload due to TLS encryption. We need to tell
// the handler how many bytes of the original data we already processed.
- this->invoke_now(m_ec, m_ec ? 0 : m_plainBytesTransferred);
+ this->complete_now(ec, ec ? 0 : m_plainBytesTransferred);
}
}