mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
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:
@@ -178,10 +178,10 @@ TEST_F(CoroutineGroupTests, SpawnForeign)
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
CoroutineGroup group{yield, 1};
|
||||
|
||||
auto const onForeignComplete = group.registerForeign();
|
||||
auto const onForeignComplete = group.registerForeign(yield);
|
||||
[&]() { ASSERT_TRUE(onForeignComplete.has_value()); }();
|
||||
|
||||
[&]() { ASSERT_FALSE(group.registerForeign().has_value()); }();
|
||||
[&]() { ASSERT_FALSE(group.registerForeign(yield).has_value()); }();
|
||||
|
||||
boost::asio::spawn(ctx_, [this, &onForeignComplete](boost::asio::yield_context innerYield) {
|
||||
boost::asio::steady_timer timer{innerYield.get_executor(), std::chrono::milliseconds{2}};
|
||||
|
||||
Reference in New Issue
Block a user