From 58ec0ed8d835772607d061d0685bf0554734dae2 Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Mon, 12 May 2025 19:05:43 +0100 Subject: [PATCH] fix: Guarantee async behaviour of WsBase::send (#2100) --- src/web/impl/WsBase.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/web/impl/WsBase.hpp b/src/web/impl/WsBase.hpp index 9be6b334a..bdd6d8603 100644 --- a/src/web/impl/WsBase.hpp +++ b/src/web/impl/WsBase.hpp @@ -173,7 +173,8 @@ public: void send(std::shared_ptr msg) override { - boost::asio::dispatch( + // Note: post used instead of dispatch to guarantee async behavior of wsFail and maybeSendNext + boost::asio::post( derived().ws().get_executor(), [this, self = derived().shared_from_this(), msg = std::move(msg)]() { if (messages_.size() > maxSendingQueueSize_) {