diff --git a/src/output/output.cpp b/src/output/output.cpp index 618c7af4..b103cf65 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -167,22 +167,30 @@ namespace Mist { if (statsPage.getData()){ statsPage.finish(); } - statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true); if (nProxy.userClient.getData()){ nProxy.userClient.finish(); } char userPageName[NAME_BUFFER_SIZE]; snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str()); - nProxy.userClient = IPC::sharedClient(userPageName, PLAY_EX_SIZE, true); + unsigned int attempts = 0; + while (!nProxy.userClient.isAlive() && ++attempts < 20 && Util::streamAlive(streamName)){ + nProxy.userClient = IPC::sharedClient(userPageName, PLAY_EX_SIZE, true); + } + if (!nProxy.userClient.isAlive()){ + FAIL_MSG("Could not register as client for %s", streamName.c_str()); + onFail(); + return; + } char pageId[NAME_BUFFER_SIZE]; snprintf(pageId, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str()); nProxy.metaPages.clear(); nProxy.metaPages[0].init(pageId, DEFAULT_STRM_PAGE_SIZE); if (!nProxy.metaPages[0].mapped){ - FAIL_MSG("Could not connect to server for %s", streamName.c_str()); + FAIL_MSG("Could not connect to data for %s", streamName.c_str()); onFail(); return; } + statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true); stats(true); updateMeta(); selectDefaultTracks();