Skip to content

Commit cca73be

Browse files
berndgassmannBlyron
authored andcommitted
Extend ROS2 support Step 0: Stabilize server unit tests
streaming.stream_outlives_server was often segfaulting. This fixes the issue. At least the test runs with 100 repetition without any issue. Previously one was lucky if 10 repetitions succeed.
1 parent 40ac1f1 commit cca73be

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

LibCarla/source/carla/ThreadPool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <future>
1818
#include <thread>
19+
#include <chrono>
1920
#include <type_traits>
2021

2122
namespace carla {
@@ -29,6 +30,11 @@ namespace carla {
2930
/// Stops the ThreadPool and joins all its threads.
3031
~ThreadPool() {
3132
Stop();
33+
// Give some time to boost asio to properly stop.
34+
// below 20ms this might be useless if there is heavy load.
35+
// Without this, segmentation faults were observed
36+
// within the boost asio code on destruction of the io_context.
37+
std::this_thread::sleep_for(std::chrono::milliseconds(20));
3238
}
3339

3440
/// Return the underlying io_context.

0 commit comments

Comments
 (0)