From c984ba37ccec622b17d7df80efad3a3808050a8a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 15 Oct 2012 00:10:15 +0200 Subject: [PATCH] sectionsd: make sure housekeeping exits on shutdown --- src/eitd/sectionsd.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index fffd3bcae..787c3cd88 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -1917,10 +1917,14 @@ static void *houseKeepingThread(void *) count = 0; } - int rc = HOUSEKEEPING_SLEEP; + int i = HOUSEKEEPING_SLEEP; - while (rc) - rc = sleep(rc); + while (i > 0 && !sectionsd_stop) { + sleep(1); + i--; + } + if (sectionsd_stop) + break; while (!scanning) { sleep(1); // wait for streaming to end... @@ -2119,7 +2123,12 @@ printf("SIevent size: %d\n", sizeof(SIevent)); 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); + xprintf("join Housekeeping\n"); + pthread_join(threadHouseKeeping, NULL); xprintf("join TOT\n"); threadTIME.Stop();