From 108499bc58e5d3d8160723ec3cc43441cd542c1a Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 22 May 2017 16:11:00 +0200 Subject: [PATCH 1/3] Meta::toFile now returns, as it should --- lib/dtscmeta.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp index 99449332..303134f1 100644 --- a/lib/dtscmeta.cpp +++ b/lib/dtscmeta.cpp @@ -1988,7 +1988,9 @@ namespace DTSC { bool Meta::toFile(const std::string & fileName){ std::ofstream oFile(fileName.c_str()); oFile << toJSON().toNetPacked(); + if (!oFile.good()){return false;} oFile.close(); + return true; } ///\brief Converts a meta object to a human readable string From 422c839ae2d40a0a14a72418091e9e303c708192 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 23 May 2017 21:21:21 +0200 Subject: [PATCH 2/3] Fix semaphore segfault when tryWait'ing on invalid semaphore. --- lib/shared_memory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 0f93d803..24421402 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -222,6 +222,7 @@ namespace IPC { ///\brief Tries to wait for the semaphore, returns true if successful, false otherwise bool semaphore::tryWait() { + if (!(*this)){return false;} int result; #if defined(__CYGWIN__) || defined(_WIN32) result = WaitForSingleObject(mySem, 0);//wait at most 1ms @@ -237,6 +238,7 @@ namespace IPC { ///\brief Tries to wait for the semaphore for a single second, returns true if successful, false otherwise bool semaphore::tryWaitOneSecond() { + if (!(*this)){return false;} int result; #if defined(__CYGWIN__) || defined(_WIN32) result = WaitForSingleObject(mySem, 1000);//wait at most 1s From 24a1744b7ec264ef71d4d4bbbbe52f3297751131 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 23 May 2017 21:26:35 +0200 Subject: [PATCH 3/3] Input now prints message and aborts cleanly when pull lock could not be opened. --- src/input/input.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/input/input.cpp b/src/input/input.cpp index dab14d13..6c323cd9 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -284,6 +284,10 @@ namespace Mist { void Input::stream(){ IPC::semaphore pullLock; pullLock.open(std::string("/MstPull_" + streamName).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1); + if (!pullLock){ + FAIL_MSG("Could not open pull lock for stream '%s' - aborting!", streamName.c_str()); + return; + } if (!pullLock.tryWait()){ WARN_MSG("A pull process for stream %s is already running", streamName.c_str()); pullLock.close();