From 7e5d7264ae02b054e368a6c08bc6083f093d23e7 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 15 Dec 2014 18:16:08 +0100 Subject: [PATCH] Fixed race condition when disconnecting shared memory client elements. --- lib/shared_memory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 85dd0d16..a436df59 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -718,6 +718,7 @@ namespace IPC { empty = (char *)malloc(payLen * sizeof(char)); memset(empty, 0, payLen); } + semGuard tmpGuard(&mySemaphore); unsigned int id = 0; for (std::set::iterator it = myPages.begin(); it != myPages.end(); it++) { if (!it->mapped || !it->len) { @@ -915,6 +916,7 @@ namespace IPC { return; } if (myPage.mapped) { + semGuard tmpGuard(&mySemaphore); myPage.mapped[offsetOnPage] = 127; } }