sectionsd: make sure housekeeping exits on shutdown

This commit is contained in:
Stefan Seyfried
2012-10-15 00:10:15 +02:00
parent 0e65041fa6
commit c984ba37cc

View File

@@ -1917,10 +1917,14 @@ static void *houseKeepingThread(void *)
count = 0; count = 0;
} }
int rc = HOUSEKEEPING_SLEEP; int i = HOUSEKEEPING_SLEEP;
while (rc) while (i > 0 && !sectionsd_stop) {
rc = sleep(rc); sleep(1);
i--;
}
if (sectionsd_stop)
break;
while (!scanning) { while (!scanning) {
sleep(1); // wait for streaming to end... sleep(1); // wait for streaming to end...
@@ -2119,7 +2123,12 @@ printf("SIevent size: %d\n", sizeof(SIevent));
xprintf("pausing...\n"); xprintf("pausing...\n");
/* sometimes, pthread_cancel seems to not work, maybe it is a bad idea to mix
* plain pthread and OpenThreads? */
sectionsd_stop = 1;
pthread_cancel(threadHouseKeeping); pthread_cancel(threadHouseKeeping);
xprintf("join Housekeeping\n");
pthread_join(threadHouseKeeping, NULL);
xprintf("join TOT\n"); xprintf("join TOT\n");
threadTIME.Stop(); threadTIME.Stop();