mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
eitd/sectionsd.cpp: stop time thread if no scanning; cleanup
This commit is contained in:
@@ -1,27 +1,30 @@
|
|||||||
//
|
/*
|
||||||
// sectionsd.cpp (network daemon for SI-sections)
|
* sectionsd.cpp (network daemon for SI-sections)
|
||||||
// (dbox-II-project)
|
* (dbox-II-project)
|
||||||
//
|
*
|
||||||
// Copyright (C) 2001 by fnbrd
|
* Copyright (C) 2001 by fnbrd (fnbrd@gmx.de)
|
||||||
//
|
* Homepage: http://dbox2.elxsi.de
|
||||||
// Homepage: http://dbox2.elxsi.de
|
*
|
||||||
//
|
* Copyright (C) 2008, 2009 Stefan Seyfried
|
||||||
// Copyright (C) 2008, 2009 Stefan Seyfried
|
*
|
||||||
//
|
* Copyright (C) 2011-2012 CoolStream International Ltd
|
||||||
// This program is free software; you can redistribute it and/or modify
|
*
|
||||||
// it under the terms of the GNU General Public License as published by
|
* License: GPLv2
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
*
|
||||||
// (at your option) any later version.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
//
|
* it under the terms of the GNU General Public License as published by
|
||||||
// This program is distributed in the hope that it will be useful,
|
* the Free Software Foundation;
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* This program is distributed in the hope that it will be useful,
|
||||||
// GNU General Public License for more details.
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
//
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// You should have received a copy of the GNU General Public License
|
* GNU General Public License for more details.
|
||||||
// along with this program; if not, write to the Free Software
|
*
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* You should have received a copy of the GNU General Public License
|
||||||
//
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@@ -56,7 +59,6 @@
|
|||||||
#include <eventserver.h>
|
#include <eventserver.h>
|
||||||
#include <driver/abstime.h>
|
#include <driver/abstime.h>
|
||||||
|
|
||||||
#include "dmxapi.h"
|
|
||||||
#include "eitd.h"
|
#include "eitd.h"
|
||||||
#include "edvbstring.h"
|
#include "edvbstring.h"
|
||||||
#include "xmlutil.h"
|
#include "xmlutil.h"
|
||||||
@@ -123,8 +125,6 @@ static t_channel_id messaging_current_servicekey = 0;
|
|||||||
static bool channel_is_blacklisted = false;
|
static bool channel_is_blacklisted = false;
|
||||||
|
|
||||||
bool timeset = false;
|
bool timeset = false;
|
||||||
//pthread_cond_t timeIsSetCond = PTHREAD_COND_INITIALIZER;
|
|
||||||
//pthread_mutex_t timeIsSetMutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
static int messaging_have_CN = 0x00; // 0x01 = CURRENT, 0x02 = NEXT
|
static int messaging_have_CN = 0x00; // 0x01 = CURRENT, 0x02 = NEXT
|
||||||
static int messaging_got_CN = 0x00; // 0x01 = CURRENT, 0x02 = NEXT
|
static int messaging_got_CN = 0x00; // 0x01 = CURRENT, 0x02 = NEXT
|
||||||
@@ -137,9 +137,6 @@ static CEventServer *eventServer;
|
|||||||
static pthread_rwlock_t servicesLock = PTHREAD_RWLOCK_INITIALIZER; // Unsere (fast-)mutex, damit nicht gleichzeitig in die Menge services geschrieben und gelesen wird
|
static pthread_rwlock_t servicesLock = PTHREAD_RWLOCK_INITIALIZER; // Unsere (fast-)mutex, damit nicht gleichzeitig in die Menge services geschrieben und gelesen wird
|
||||||
static pthread_rwlock_t messagingLock = PTHREAD_RWLOCK_INITIALIZER;
|
static pthread_rwlock_t messagingLock = PTHREAD_RWLOCK_INITIALIZER;
|
||||||
|
|
||||||
//static pthread_cond_t timeThreadSleepCond = PTHREAD_COND_INITIALIZER;
|
|
||||||
//static pthread_mutex_t timeThreadSleepMutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
static CTimeThread threadTIME;
|
static CTimeThread threadTIME;
|
||||||
static CEitThread threadEIT;
|
static CEitThread threadEIT;
|
||||||
static CCNThread threadCN;
|
static CCNThread threadCN;
|
||||||
@@ -204,22 +201,6 @@ inline void unlockEvents(void)
|
|||||||
pthread_rwlock_unlock(&eventsLock);
|
pthread_rwlock_unlock(&eventsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
inline bool waitForTimeset(void)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&timeIsSetMutex);
|
|
||||||
while(!timeset)
|
|
||||||
pthread_cond_wait(&timeIsSetCond, &timeIsSetMutex);
|
|
||||||
pthread_mutex_unlock(&timeIsSetMutex);
|
|
||||||
/* we have time synchronization issues, at least on kernel 2.4, so
|
|
||||||
sometimes the time in the threads is still 1.1.1970, even after
|
|
||||||
waitForTimeset() returns. Let's hope that we work around this issue
|
|
||||||
with this sleep */
|
|
||||||
sleep(1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const SIevent nullEvt; // Null-Event
|
static const SIevent nullEvt; // Null-Event
|
||||||
|
|
||||||
static MySIeventsOrderUniqueKey mySIeventsOrderUniqueKey;
|
static MySIeventsOrderUniqueKey mySIeventsOrderUniqueKey;
|
||||||
@@ -855,10 +836,10 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng
|
|||||||
threadCN.request_pause();
|
threadCN.request_pause();
|
||||||
threadEIT.request_pause();
|
threadEIT.request_pause();
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
dmxFSEIT.request_pause();
|
threadFSEIT.request_pause();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SDT
|
#ifdef ENABLE_SDT
|
||||||
dmxSDT.request_pause();
|
threadSDT.request_pause();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
scanning = 0;
|
scanning = 0;
|
||||||
@@ -869,10 +850,10 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng
|
|||||||
threadCN.request_unpause();
|
threadCN.request_unpause();
|
||||||
threadEIT.request_unpause();
|
threadEIT.request_unpause();
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
dmxFSEIT.request_unpause();
|
threadFSEIT.request_unpause();
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SDT
|
#ifdef ENABLE_SDT
|
||||||
dmxSDT.request_unpause();
|
threadSDT.request_unpause();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
writeLockEvents();
|
writeLockEvents();
|
||||||
@@ -888,20 +869,16 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng
|
|||||||
unlockMessaging();
|
unlockMessaging();
|
||||||
|
|
||||||
scanning = 1;
|
scanning = 1;
|
||||||
if (!ntpenable) //FIXME flag if ntp update was good ?
|
/* FIXME should we stop time updates if not scanning ? flag if ntp update was good ? */
|
||||||
|
if (!ntpenable)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
pthread_mutex_lock(&timeThreadSleepMutex);
|
|
||||||
pthread_cond_broadcast(&timeThreadSleepCond);
|
|
||||||
pthread_mutex_unlock(&timeThreadSleepMutex);
|
|
||||||
#endif
|
|
||||||
threadTIME.change(0);
|
threadTIME.change(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
threadCN.change(0);
|
threadCN.change(0);
|
||||||
threadEIT.change(0);
|
threadEIT.change(0);
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
dmxFSEIT.change(0);
|
threadFSEIT.change(0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SDT
|
#ifdef ENABLE_SDT
|
||||||
threadSDT.change(0);
|
threadSDT.change(0);
|
||||||
@@ -921,12 +898,11 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen
|
|||||||
uniqueServiceKey = (((sectionsd::commandSetServiceChanged *)data)->channel_id);
|
uniqueServiceKey = (((sectionsd::commandSetServiceChanged *)data)->channel_id);
|
||||||
uniqueServiceKey &= 0xFFFFFFFFFFFFULL;
|
uniqueServiceKey &= 0xFFFFFFFFFFFFULL;
|
||||||
|
|
||||||
dprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n", uniqueServiceKey);
|
xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
||||||
xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
|
||||||
|
|
||||||
static t_channel_id time_trigger_last = 0;
|
static t_channel_id time_trigger_last = 0;
|
||||||
|
|
||||||
if (uniqueServiceKey && messaging_current_servicekey != uniqueServiceKey) {
|
if (messaging_current_servicekey != uniqueServiceKey) {
|
||||||
dvb_time_update = !checkNoDVBTimelist(uniqueServiceKey);
|
dvb_time_update = !checkNoDVBTimelist(uniqueServiceKey);
|
||||||
dprintf("[sectionsd] commandserviceChanged: DVB time update is %s\n", dvb_time_update ? "allowed" : "blocked!");
|
dprintf("[sectionsd] commandserviceChanged: DVB time update is %s\n", dvb_time_update ? "allowed" : "blocked!");
|
||||||
|
|
||||||
@@ -950,18 +926,13 @@ xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_I
|
|||||||
threadCN.setCurrentService(messaging_current_servicekey);
|
threadCN.setCurrentService(messaging_current_servicekey);
|
||||||
threadEIT.setCurrentService(messaging_current_servicekey);
|
threadEIT.setCurrentService(messaging_current_servicekey);
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
dmxFSEIT.setCurrentService(messaging_current_servicekey);
|
threadFSEIT.setCurrentService(messaging_current_servicekey);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SDT
|
#ifdef ENABLE_SDT
|
||||||
threadSDT.setCurrentService(messaging_current_servicekey);
|
threadSDT.setCurrentService(messaging_current_servicekey);
|
||||||
#endif
|
#endif
|
||||||
if (time_trigger_last != (messaging_current_servicekey & 0xFFFFFFFF0000ULL)) {
|
if (time_trigger_last != (messaging_current_servicekey & 0xFFFFFFFF0000ULL)) {
|
||||||
time_trigger_last = messaging_current_servicekey & 0xFFFFFFFF0000ULL;
|
time_trigger_last = messaging_current_servicekey & 0xFFFFFFFF0000ULL;
|
||||||
#if 0
|
|
||||||
pthread_mutex_lock(&timeThreadSleepMutex);
|
|
||||||
pthread_cond_broadcast(&timeThreadSleepCond);
|
|
||||||
pthread_mutex_unlock(&timeThreadSleepMutex);
|
|
||||||
#endif
|
|
||||||
threadTIME.setCurrentService(messaging_current_servicekey);
|
threadTIME.setCurrentService(messaging_current_servicekey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -970,7 +941,7 @@ xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_I
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
//sendEmptyResponse(connfd, NULL, 0);
|
//sendEmptyResponse(connfd, NULL, 0);
|
||||||
xprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
xprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void commandGetIsScanningActive(int connfd, char* /*data*/, const unsigned /*dataLength*/)
|
static void commandGetIsScanningActive(int connfd, char* /*data*/, const unsigned /*dataLength*/)
|
||||||
@@ -1021,7 +992,6 @@ static void commandDumpStatusInformation(int /*connfd*/, char* /*data*/, const u
|
|||||||
char stati[MAX_SIZE_STATI];
|
char stati[MAX_SIZE_STATI];
|
||||||
|
|
||||||
snprintf(stati, MAX_SIZE_STATI,
|
snprintf(stati, MAX_SIZE_STATI,
|
||||||
"$Id: sectionsd.cpp,v 1.305 2009/07/30 12:41:39 seife Exp $\n"
|
|
||||||
"Current time: %s"
|
"Current time: %s"
|
||||||
"Hours to cache: %ld\n"
|
"Hours to cache: %ld\n"
|
||||||
"Hours to cache extended text: %ld\n"
|
"Hours to cache extended text: %ld\n"
|
||||||
@@ -1150,8 +1120,8 @@ static void deleteSIexceptEPG()
|
|||||||
threadSDT.change(0);
|
threadSDT.change(0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
dmxFSEIT.setCurrentService(messaging_current_servicekey);
|
threadFSEIT.setCurrentService(messaging_current_servicekey);
|
||||||
dmxFSEIT.change(0);
|
threadFSEIT.change(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1419,12 +1389,15 @@ void CTimeThread::run()
|
|||||||
xprintf("%s: going to sleep %d seconds, running %d scanning %d\n",
|
xprintf("%s: going to sleep %d seconds, running %d scanning %d\n",
|
||||||
name.c_str(), sleep_time, running, scanning);
|
name.c_str(), sleep_time, running, scanning);
|
||||||
#endif
|
#endif
|
||||||
real_pause();
|
do {
|
||||||
int rs = Sleep();
|
real_pause();
|
||||||
|
int rs = Sleep();
|
||||||
#ifdef DEBUG_TIME_THREAD
|
#ifdef DEBUG_TIME_THREAD
|
||||||
xprintf("%s: wakeup, running %d scanning %d reason %d\n",
|
xprintf("%s: wakeup, running %d scanning %d channel %llx reason %d\n",
|
||||||
name.c_str(), running, scanning, rs);
|
name.c_str(), running, scanning, current_service, rs);
|
||||||
#endif
|
#endif
|
||||||
|
} while (running && !scanning);
|
||||||
|
|
||||||
if (!running)
|
if (!running)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1454,7 +1427,8 @@ void CTimeThread::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* default sleep time */
|
/* default sleep time */
|
||||||
sleep_time = ntprefresh * 60;
|
//sleep_time = ntprefresh * 60;
|
||||||
|
sleep_time = 10;
|
||||||
if(success) {
|
if(success) {
|
||||||
if(dvb_time) {
|
if(dvb_time) {
|
||||||
setSystemTime(dvb_time);
|
setSystemTime(dvb_time);
|
||||||
@@ -1474,7 +1448,6 @@ void CTimeThread::run()
|
|||||||
}
|
}
|
||||||
sendToSleepNow = true;
|
sendToSleepNow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] static_buf;
|
delete[] static_buf;
|
||||||
printf("[sectionsd] timeThread ended\n");
|
printf("[sectionsd] timeThread ended\n");
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
@@ -1689,7 +1662,6 @@ void CEitThread::addFilters()
|
|||||||
|
|
||||||
void CEitThread::beforeSleep()
|
void CEitThread::beforeSleep()
|
||||||
{
|
{
|
||||||
xprintf("%s: CScheduledThread::beforeSleep()\n", name.c_str());
|
|
||||||
writeLockMessaging();
|
writeLockMessaging();
|
||||||
messaging_zap_detected = false;
|
messaging_zap_detected = false;
|
||||||
unlockMessaging();
|
unlockMessaging();
|
||||||
@@ -2054,7 +2026,7 @@ void sectionsd_main_thread(void * /*data*/)
|
|||||||
pthread_t /*threadTOT,*/ threadHouseKeeping;
|
pthread_t /*threadTOT,*/ threadHouseKeeping;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
printf("$Id: sectionsd.cpp,v 1.305 2009/07/30 12:41:39 seife Exp $\n");
|
xpritf("[sectionsd] starting\n");
|
||||||
printf("SIevent size: %d\n", sizeof(SIevent));
|
printf("SIevent size: %d\n", sizeof(SIevent));
|
||||||
|
|
||||||
/* "export NO_SLOW_ADDEVENT=true" to disable this */
|
/* "export NO_SLOW_ADDEVENT=true" to disable this */
|
||||||
@@ -2109,18 +2081,8 @@ printf("SIevent size: %d\n", sizeof(SIevent));
|
|||||||
|
|
||||||
eventServer = new CEventServer;
|
eventServer = new CEventServer;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// time-Thread starten
|
|
||||||
rc = pthread_create(&threadTOT, 0, timeThread, 0);
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
fprintf(stderr, "[sectionsd] failed to create time-thread (rc=%d)\n", rc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
threadTIME.Start();
|
threadTIME.Start();
|
||||||
threadEIT.Start();
|
threadEIT.Start();
|
||||||
|
|
||||||
threadCN.Start();
|
threadCN.Start();
|
||||||
|
|
||||||
#ifdef ENABLE_FREESATEPG
|
#ifdef ENABLE_FREESATEPG
|
||||||
@@ -2165,35 +2127,16 @@ printf("SIevent size: %d\n", sizeof(SIevent));
|
|||||||
threadTIME.StopRun();
|
threadTIME.StopRun();
|
||||||
|
|
||||||
xprintf("broadcasting...\n");
|
xprintf("broadcasting...\n");
|
||||||
#if 0
|
|
||||||
timeset = true;
|
|
||||||
pthread_mutex_lock(&timeIsSetMutex);
|
|
||||||
pthread_cond_broadcast(&timeIsSetCond);
|
|
||||||
pthread_mutex_unlock(&timeIsSetMutex);
|
|
||||||
#endif
|
|
||||||
threadTIME.setTimeSet();
|
threadTIME.setTimeSet();
|
||||||
#if 0
|
|
||||||
pthread_mutex_lock(&timeThreadSleepMutex);
|
|
||||||
pthread_cond_broadcast(&timeThreadSleepCond);
|
|
||||||
pthread_mutex_unlock(&timeThreadSleepMutex);
|
|
||||||
#endif
|
|
||||||
xprintf("pausing...\n");
|
xprintf("pausing...\n");
|
||||||
|
|
||||||
pthread_cancel(threadHouseKeeping);
|
pthread_cancel(threadHouseKeeping);
|
||||||
|
|
||||||
//if (dmxUTC) dmxUTC->Stop();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
xprintf("cancel TOT\n");
|
|
||||||
//threadTIME.cancel();
|
|
||||||
//pthread_cancel(threadTOT);
|
|
||||||
#endif
|
|
||||||
xprintf("join TOT\n");
|
xprintf("join TOT\n");
|
||||||
//pthread_join(threadTOT, NULL);
|
|
||||||
threadTIME.Stop();
|
threadTIME.Stop();
|
||||||
|
|
||||||
//if (dmxUTC) delete dmxUTC;
|
|
||||||
|
|
||||||
xprintf("join EIT\n");
|
xprintf("join EIT\n");
|
||||||
threadEIT.Stop();
|
threadEIT.Stop();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user