From 254fb94b62b28eeab13c4fc6279400123ed8ecbd Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 23 May 2016 11:48:59 +0200 Subject: [PATCH] Fixed reconnect() sometimes segfaulting for live streams on first attempt. --- src/output/output.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/output/output.cpp b/src/output/output.cpp index 403a31b1..439e573f 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -75,11 +75,16 @@ namespace Mist { //read metadata from page to myMeta variable if (nProxy.metaPages[0].mapped){ IPC::semaphore * liveSem = 0; - if (myMeta.live){ + if (!myMeta.vod){ static char liveSemName[NAME_BUFFER_SIZE]; snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str()); - liveSem = new IPC::semaphore(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1); - liveSem->wait(); + liveSem = new IPC::semaphore(liveSemName, O_RDWR, ACCESSPERMS, 1); + if (*liveSem){ + liveSem->wait(); + }else{ + delete liveSem; + liveSem = 0; + } } DTSC::Packet tmpMeta(nProxy.metaPages[0].mapped, nProxy.metaPages[0].len, true); if (tmpMeta.getVersion()){