From 4dc3d22d12b3b22ae4d8435ca8f00b6015d969c7 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Thu, 28 Jul 2016 20:41:44 +0200
Subject: [PATCH] Fixed potential deadlock in buffer when a past crash has
 happened

---
 lib/shared_memory.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp
index 0faf16a2..d0041fd5 100644
--- a/lib/shared_memory.cpp
+++ b/lib/shared_memory.cpp
@@ -766,6 +766,10 @@ namespace IPC {
       DEBUG_MSG(DLVL_FAIL, "Creating semaphore failed: %s", strerror(errno));
       return;
     }
+    if (!mySemaphore.tryWaitOneSecond()){
+      WARN_MSG("Force unlocking sharedServer semaphore to prevent deadlock");
+    }
+    mySemaphore.post();
     semGuard tmpGuard(&mySemaphore);
     newPage();
   }