From 80f94636a43eededfa18a91425b6fe5f5af8f8be Mon Sep 17 00:00:00 2001 From: cryptocode Date: Fri, 24 Jan 2020 12:02:55 +0100 Subject: [PATCH] Fix bootstrap_exited segfault on macos (#2510) --- nano/core_test/websocket.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/nano/core_test/websocket.cpp b/nano/core_test/websocket.cpp index ef9bb41e..0630af8b 100644 --- a/nano/core_test/websocket.cpp +++ b/nano/core_test/websocket.cpp @@ -877,18 +877,13 @@ TEST (websocket, bootstrap_exited) // Start bootstrap, exit after subscription std::atomic bootstrap_started{ false }; - std::atomic subscribed{ false }; - std::thread bootstrap_thread ([node1, &bootstrap_started, &subscribed]() { + nano::util::counted_completion subscribed_completion (1); + std::thread bootstrap_thread ([node1, &bootstrap_started, &subscribed_completion]() { node1->bootstrap_initiator.bootstrap (true, "123abc"); auto attempt (node1->bootstrap_initiator.current_attempt ()); ASSERT_NE (nullptr, attempt); bootstrap_started = true; - nano::system system2; - system2.deadline_set (5s); - while (!subscribed) - { - ASSERT_NO_ERROR (system2.poll ()); - } + ASSERT_FALSE (subscribed_completion.await_count_for (5s)); }); // Wait for bootstrap start @@ -915,7 +910,7 @@ TEST (websocket, bootstrap_exited) ASSERT_EQ (1, node1->websocket_server->subscriber_count (nano::websocket::topic::bootstrap)); // Wait for the bootstrap notification - subscribed = true; + subscribed_completion.increment (); bootstrap_thread.join (); system.deadline_set (5s); while (client_future.wait_for (std::chrono::seconds (0)) != std::future_status::ready) @@ -959,4 +954,4 @@ TEST (websocket, ws_keepalive) ASSERT_NO_ERROR (system.poll ()); } subscription_thread.join (); -} \ No newline at end of file +}