[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/LOOLForKit.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/Util.cpp loolwsd/Util.hpp
Miklos Vajna
vmiklos at collabora.co.uk
Wed Jun 15 13:56:49 UTC 2016
loolwsd/Admin.cpp | 2 +-
loolwsd/LOOLForKit.cpp | 2 +-
loolwsd/LOOLKit.cpp | 2 +-
loolwsd/LOOLWSD.cpp | 2 +-
loolwsd/Util.cpp | 2 +-
loolwsd/Util.hpp | 3 ++-
6 files changed, 7 insertions(+), 6 deletions(-)
New commits:
commit afb6a7ebb025bad3e4a90119ef95d09e7b4bf5d8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jun 15 15:31:41 2016 +0200
Util: turn TerminationFlag into an std::atomic<bool>
Running unit-fonts under helgrind points out missing synchronization
there.
diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp
index 8c8bf80..e9344d6 100644
--- a/loolwsd/Admin.cpp
+++ b/loolwsd/Admin.cpp
@@ -194,7 +194,7 @@ void AdminRequestHandler::handleWSRequests(HTTPServerRequest& request, HTTPServe
return adminCommandHandler(payload);
},
[]() { },
- []() { return TerminationFlag; });
+ []() { return TerminationFlag.load(); });
Log::debug() << "Finishing Admin Session " << Util::encodeId(sessionId);
}
diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index 60a3b8e..48ad394 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -68,7 +68,7 @@ public:
bool pollAndDispatch()
{
std::string line;
- const auto ready = readLine(line, [](){ return TerminationFlag; });
+ const auto ready = readLine(line, [](){ return TerminationFlag.load(); });
if (ready == 0)
{
// Timeout.
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 074a263..d063fc8 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1227,7 +1227,7 @@ void lokit_main(const std::string& childRoot,
{
if (document && document->canDiscard())
TerminationFlag = true;
- return TerminationFlag;
+ return TerminationFlag.load();
});
// Clean up jail if we created one
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index c6d1d63..b210206 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1034,7 +1034,7 @@ public:
return session->handleInput(payload.data(), payload.size());
},
[&session]() { session->closeFrame(); },
- []() { return TerminationFlag; });
+ []() { return TerminationFlag.load(); });
if (session->isCloseFrame())
{
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index f6bfa78..3920ae1 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -43,7 +43,7 @@
#include "Common.hpp"
#include "Log.hpp"
-volatile bool TerminationFlag = false;
+std::atomic<bool> TerminationFlag(false);
namespace Util
{
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 38b2268..b3065a4 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -16,6 +16,7 @@
#include <set>
#include <sstream>
#include <string>
+#include <atomic>
#include <Poco/File.h>
#include <Poco/Net/WebSocket.h>
@@ -27,7 +28,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
/// Flag to stop pump loops.
-extern volatile bool TerminationFlag;
+extern std::atomic<bool> TerminationFlag;
namespace Util
{
More information about the Libreoffice-commits
mailing list