diff --git a/lib/defines.h b/lib/defines.h index 5da8a135..55ba3a17 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -46,9 +46,9 @@ static const char * DBG_LVL_LIST[] = {"NONE", "FAIL", "ERROR", "WARN", "INFO", " #endif #else #if DEBUG >= DLVL_DEVEL -#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, __LINE__, Util::Config::streamName.c_str(), ##__VA_ARGS__);} +#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|MistProcess|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, __LINE__, Util::Config::streamName.c_str(), ##__VA_ARGS__);} #else -#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d||%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), Util::Config::streamName.c_str(), ##__VA_ARGS__);} +#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|MistProcess|%d||%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), Util::Config::streamName.c_str(), ##__VA_ARGS__);} #endif #endif diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 0e8b690b..b6b2cf9c 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -122,6 +122,14 @@ namespace IPC { #else if (oflag & O_CREAT) { mySem = sem_open(name, oflag, mode, value); +#if defined(__APPLE__) + if (!(*this)){ + if (sem_unlink(name) == 0){ + INFO_MSG("Deleted in-use semaphore: %s", name); + mySem = sem_open(name, oflag, mode, value); + } + } +#endif } else { mySem = sem_open(name, oflag); } diff --git a/lib/stream.cpp b/lib/stream.cpp index f9820db8..24264fb2 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -230,7 +230,7 @@ DTSC::Meta Util::getStreamMeta(const std::string &streamname){ bool Util::streamAlive(std::string &streamname){ char semName[NAME_BUFFER_SIZE]; snprintf(semName, NAME_BUFFER_SIZE, SEM_INPUT, streamname.c_str()); - IPC::semaphore playerLock(semName, O_RDWR, ACCESSPERMS, 1, true); + IPC::semaphore playerLock(semName, O_RDWR, ACCESSPERMS, 0, true); if (!playerLock){return false;} if (!playerLock.tryWait()){ playerLock.close();