fix: Data race in new webserver (#1926)

There was a data race inside `CoroutineGroup` because internal timer was
used from multiple threads in the methods `asyncWait()` and
`onCoroutineComplete()`. Changing `registerForeign()` to spawn to the
same `yield_context` fixes the problem because now the timer is accessed
only from the same coroutine which has an internal strand.

During debugging I also added websocket support for `request_gun` tool.
This commit is contained in:
Sergey Kuznetsov
2025-02-27 15:08:46 +00:00
committed by GitHub
parent b909b8879d
commit d11e7bc60e
13 changed files with 116 additions and 32 deletions

View File

@@ -73,10 +73,11 @@ public:
* @note A foreign coroutine is still counted as a child one, i.e. calling this method increases the size of the
* group.
*
* @param yield The yield context owning the coroutine group.
* @return A callback to call on foreign coroutine completes or std::nullopt if the group is already full.
*/
std::optional<std::function<void()>>
registerForeign();
registerForeign(boost::asio::yield_context yield);
/**
* @brief Wait for all the coroutines in the group to finish