aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/asio/asio_stream.h
diff options
context:
space:
mode:
authorHannes Rantzsch <[email protected]>2019-02-19 18:04:56 +0100
committerHannes Rantzsch <[email protected]>2019-04-16 10:47:48 +0200
commit9136b994ca305c47950ea465955c044137b0f4a3 (patch)
treedb8dcf0828265d085302bd881c64077584cfc084 /src/lib/tls/asio/asio_stream.h
parent906495bcec08a6933e0d8eae44dbd35dd01e78c7 (diff)
don't call async_write handler directly
Diffstat (limited to 'src/lib/tls/asio/asio_stream.h')
-rw-r--r--src/lib/tls/asio/asio_stream.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h
index 4406fb80a..72f363a88 100644
--- a/src/lib/tls/asio/asio_stream.h
+++ b/src/lib/tls/asio/asio_stream.h
@@ -390,21 +390,23 @@ class Stream final : public StreamBase<Channel>
boost::asio::detail::buffer_sequence_adapter<
boost::asio::const_buffer, ConstBufferSequence>::first(buffers);
+ boost::asio::async_completion<WriteHandler,
+ void(boost::system::error_code, std::size_t)>
+ init(handler);
+
try
{
+ // NOTE: This is not asynchronous: it encrypts the data synchronously.
+ // Only writing on the socket is asynchronous.
native_handle()->send(static_cast<const uint8_t*>(buffer.data()),
buffer.size());
}
catch(...)
{
- // TODO: don't call directly
- handler(Botan::TLS::convertException(), 0);
- return;
+ init.completion_handler(Botan::TLS::convertException(), 0);
+ return init.result.get();
}
- boost::asio::async_completion<WriteHandler,
- void(boost::system::error_code, std::size_t)>
- init(handler);
auto op = create_async_write_op(std::move(init.completion_handler),
buffer.size());