From 0f771856ab8b9aa0d597f5deed780ba87971ce71 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 22 Feb 2016 18:03:27 +0300 Subject: [PATCH] nhttpd/tuxboxapi/neutrinoyparser.cpp: copy event to prevent crash in multi-threaded mode --- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 1d0f4ae4e..203012bc0 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -358,9 +358,12 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: for(int j = 0; j < (int) channels.size(); j++) { CZapitChannel * channel = channels[j]; - CChannelEvent *event; + CChannelEvent event; + event.eventID = 0; NeutrinoAPI->Lock(); - event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()]; + CChannelEvent * evt = NeutrinoAPI->ChannelListEvents[channel->getChannelID()]; + if (evt) + event = *evt; NeutrinoAPI->Unlock(); classname = (i++ & 1) ? 'a' : 'b'; @@ -399,9 +402,9 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: } /* timer slider */ - if(event && event->duration > 0) + if(event.eventID && event.duration > 0) { - prozent = 100 * (time(NULL) - event->startTime) / event->duration; + prozent = 100 * (time(NULL) - event.startTime) / event.duration; yresult += string_printf("
\n" "\t" "" @@ -441,7 +444,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: (channel->getServiceType() == ST_NVOD_REFERENCE_SERVICE) ? " (NVOD)" : "", channel->getChannelID(), channel->getChannelID() & 0xFFFFFFFFFFFFULL, - (event ? "\"Program" : "")); + (event.eventID ? "\"Program" : "")); if (channel->getChannelID() == current_channel) yresult += string_printf("\n  \"Streaminfo\""); @@ -491,11 +494,11 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: } } - else if (event) + else if (event.eventID) { bool has_current_next = true; CEitManager::getInstance()->getCurrentNextServiceKey(channel->getChannelID(), currentNextInfo); - timestr = timeString(event->startTime); + timestr = timeString(event.startTime); CShortEPGData epg; std::string EPGInfoC = ""; @@ -510,9 +513,9 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: "(%ld {=L:from=} %d {=L:unit.short.minute=}, %d%%)" , timestr.c_str() , EPGInfoC.c_str() - , event->description.c_str() - , (time(NULL) - event->startTime)/60 - , event->duration / 60,prozent); + , event.description.c_str() + , (time(NULL) - event.startTime)/60 + , event.duration / 60,prozent); if ((has_current_next) && (currentNextInfo.flags & CSectionsdClient::epgflags::has_next)) { std::string EPGInfoN = "";