From daf0e9d82075e4f2bf9dc73267acc282c5d4bd1d Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Mon, 8 Jan 2007 11:57:48 +0000 Subject: [PATCH 1/1] some thread related fixes --- lib/dvb/epgcache.cpp | 28 +++++++++++++++++----------- lib/dvb/pmt.cpp | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index 4d055a6e..47ebb355 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -715,7 +715,7 @@ void eEPGCache::cleanLoop() content_time_tables.find( DBIt->first ); if ( x != content_time_tables.end() ) { - timeMap &tmMap = eventDB[DBIt->first].second; + timeMap &tmMap = DBIt->second.second; for ( contentMap::iterator i = x->second.begin(); i != x->second.end(); ) { for ( contentTimeMap::iterator it(i->second.begin()); @@ -782,6 +782,7 @@ void eEPGCache::gotMessage( const Message &msg ) #ifdef ENABLE_PRIVATE_EPG case Message::got_private_pid: { + singleLock s(channel_map_lock); for (channelMapIterator it(m_knownChannels.begin()); it != m_knownChannels.end(); ++it) { eDVBChannel *channel = (eDVBChannel*) it->first; @@ -1478,6 +1479,7 @@ RESULT eEPGCache::lookupEventId(const eServiceReference &service, int event_id, RESULT eEPGCache::startTimeQuery(const eServiceReference &service, time_t begin, int minutes) { + Lock(); eventCache::iterator It = eventDB.find(handleGroup(service)); if ( It != eventDB.end() && It->second.second.size() ) { @@ -1504,8 +1506,10 @@ RESULT eEPGCache::startTimeQuery(const eServiceReference &service, time_t begin, m_timemap_cursor = It->second.second.begin(); const eServiceReferenceDVB &ref = (const eServiceReferenceDVB&)handleGroup(service); currentQueryTsidOnid = (ref.getTransportStreamID().get()<<16) | ref.getOriginalNetworkID().get(); + Unlock(); return 0; } + Unlock(); return -1; } @@ -2525,7 +2529,7 @@ void eEPGCache::channel_data::startPrivateReader() void eEPGCache::channel_data::readPrivateData( const __u8 *data) { - if ( seenPrivateSections.find( data[6] ) == seenPrivateSections.end() ) + if ( seenPrivateSections.find(data[6]) == seenPrivateSections.end() ) { cache->privateSectionRead(m_PrivateService, data); seenPrivateSections.insert(data[6]); @@ -2602,19 +2606,21 @@ void eEPGCache::channel_data::timeMHW2DVB( u_char day, u_char hours, u_char minu putenv("TZ=CET-1CEST,M3.5.0/2,M10.5.0/3"); tzset(); - tm *localnow = localtime( &dt ); + tm localnow; + localtime_r(&dt, &localnow); if (day == 7) day = 0; - if ( day + 1 < localnow->tm_wday ) // day + 1 to prevent old events to show for next week. + if ( day + 1 < localnow.tm_wday ) // day + 1 to prevent old events to show for next week. day += 7; if (local_hours <= 5) day++; - dt += 3600*24*(day - localnow->tm_wday); // Shift dt to the recording date (local time zone). - dt += 3600*(local_hours - localnow->tm_hour); // Shift dt to the recording hour. + dt += 3600*24*(day - localnow.tm_wday); // Shift dt to the recording date (local time zone). + dt += 3600*(local_hours - localnow.tm_hour); // Shift dt to the recording hour. - tm *recdate = gmtime( &dt ); // This will also take care of DST. + tm recdate; + gmtime_r( &dt, &recdate ); // This will also take care of DST. if ( old_tz == NULL ) unsetenv( "TZ" ); @@ -2624,15 +2630,15 @@ void eEPGCache::channel_data::timeMHW2DVB( u_char day, u_char hours, u_char minu // Calculate MJD according to annex in ETSI EN 300 468 int l=0; - if ( recdate->tm_mon <= 1 ) // Jan or Feb + if ( recdate.tm_mon <= 1 ) // Jan or Feb l=1; - int mjd = 14956 + recdate->tm_mday + int( (recdate->tm_year - l) * 365.25) + - int( (recdate->tm_mon + 2 + l * 12) * 30.6001); + int mjd = 14956 + recdate.tm_mday + int( (recdate.tm_year - l) * 365.25) + + int( (recdate.tm_mon + 2 + l * 12) * 30.6001); return_time[0] = (mjd & 0xFF00)>>8; return_time[1] = mjd & 0xFF; - timeMHW2DVB( recdate->tm_hour, minutes, return_time+2 ); + timeMHW2DVB( recdate.tm_hour, minutes, return_time+2 ); } void eEPGCache::channel_data::storeTitle(std::map<__u32, mhw_title_t>::iterator itTitle, std::string sumText, const __u8 *data) diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 33ec55c1..e7094200 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -87,9 +87,9 @@ void eDVBServicePMTHandler::PMTready(int error) { m_have_cached_program = false; serviceEvent(eventNewProgramInfo); - eEPGCache::getInstance()->PMTready(this); if (!m_pvr_channel) // don't send campmt to camd.socket for playbacked services { + eEPGCache::getInstance()->PMTready(this); if(!m_ca_servicePtr) { int demuxes[2] = {0,0}; -- 2.30.2