eitd/sectionsd.cpp: split commandFreeMemory, call FreeMemory at exit if configured

This commit is contained in:
[CST] Focus
2012-05-02 17:53:42 +04:00
parent 9382ba11a3
commit 5fe2159cab

View File

@@ -821,6 +821,18 @@ static void sendEmptyResponse(int connfd, char *, const unsigned)
// handles incoming requests // handles incoming requests
//--------------------------------------------------------------------- //---------------------------------------------------------------------
static void wakeupAll()
{
threadCN.change(0);
threadEIT.change(0);
#ifdef ENABLE_FREESATEPG
threadFSEIT.change(0);
#endif
#ifdef ENABLE_SDT
threadSDT.change(0);
#endif
}
static void commandPauseScanning(int connfd, char *data, const unsigned dataLength) static void commandPauseScanning(int connfd, char *data, const unsigned dataLength)
{ {
if (dataLength != sizeof(int)) if (dataLength != sizeof(int))
@@ -874,15 +886,7 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng
{ {
threadTIME.change(0); threadTIME.change(0);
} }
wakeupAll();
threadCN.change(0);
threadEIT.change(0);
#ifdef ENABLE_FREESATEPG
threadFSEIT.change(0);
#endif
#ifdef ENABLE_SDT
threadSDT.change(0);
#endif
} }
sendEmptyResponse(connfd, NULL, 0); sendEmptyResponse(connfd, NULL, 0);
} }
@@ -1096,25 +1100,19 @@ static void commandSetConfig(int connfd, char *data, const unsigned /*dataLength
static void deleteSIexceptEPG() static void deleteSIexceptEPG()
{ {
threadCN.dropCachedSectionIDs();
threadEIT.dropCachedSectionIDs(); threadEIT.dropCachedSectionIDs();
threadEIT.change(0);
#ifdef ENABLE_SDT #ifdef ENABLE_SDT
writeLockServices(); writeLockServices();
mySIservicesOrderUniqueKey.clear(); mySIservicesOrderUniqueKey.clear();
unlockServices(); unlockServices();
threadSDT.dropCachedSectionIDs(); threadSDT.dropCachedSectionIDs();
threadSDT.change(0);
#endif
#ifdef ENABLE_FREESATEPG
threadFSEIT.setCurrentService(messaging_current_servicekey);
threadFSEIT.change(0);
#endif #endif
} }
static void commandFreeMemory(int connfd, char * /*data*/, const unsigned /*dataLength*/) static void FreeMemory()
{ {
sendEmptyResponse(connfd, NULL, 0); xprintf("[sectionsd] free memory...\n");
deleteSIexceptEPG(); deleteSIexceptEPG();
writeLockEvents(); writeLockEvents();
@@ -1143,6 +1141,14 @@ static void commandFreeMemory(int connfd, char * /*data*/, const unsigned /*data
unlockEvents(); unlockEvents();
malloc_stats(); malloc_stats();
xprintf("[sectionsd] free memory done\n");
//wakeupAll(); //FIXME should we re-start eit here ?
}
static void commandFreeMemory(int connfd, char * /*data*/, const unsigned /*dataLength*/)
{
sendEmptyResponse(connfd, NULL, 0);
FreeMemory();
} }
static void commandReadSIfromXML(int connfd, char *data, const unsigned dataLength) static void commandReadSIfromXML(int connfd, char *data, const unsigned dataLength)
@@ -2165,6 +2171,10 @@ printf("SIevent size: %d\n", sizeof(SIevent));
#ifdef ENABLE_FREESATEPG #ifdef ENABLE_FREESATEPG
xprintf("join FSEIT\n"); xprintf("join FSEIT\n");
threadFSEIT.Stop(); threadFSEIT.Stop();
#endif
#ifdef EXIT_CLEANUP
xprintf("[sectionsd] cleanup...\n");
FreeMemory();
#endif #endif
xprintf("[sectionsd] stopped\n"); xprintf("[sectionsd] stopped\n");
} }