From 940980f501da29c75baee0194fa65a37054d73fd Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Fri, 1 Mar 2019 16:14:53 +0100 Subject: [PATCH] Fix race in defaultLoop --- src/Loop.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Loop.h b/src/Loop.h index 506f240..f030755 100644 --- a/src/Loop.h +++ b/src/Loop.h @@ -24,6 +24,7 @@ #include #include +#include namespace uWS { struct Loop { @@ -87,7 +88,7 @@ public: static Loop *defaultLoop() { /* Deliver and attach the default loop to the first thread who calls us */ static thread_local bool ownsDefaultLoop; - static Loop *defaultLoop; + static std::atomic defaultLoop; if (!defaultLoop) { ownsDefaultLoop = true; defaultLoop = create(true);