capmt/cwc: another destroy cleanups
This commit is contained in:
parent
a78c1c7bf7
commit
2494ab7115
2 changed files with 19 additions and 18 deletions
|
@ -1447,7 +1447,6 @@ capmt_thread(void *aux)
|
|||
pthread_mutex_unlock(&global_lock);
|
||||
}
|
||||
|
||||
capmt_flush_queue(capmt, 1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1843,14 +1842,16 @@ capmt_destroy(capmt_t *capmt)
|
|||
lock_assert(&global_lock);
|
||||
TAILQ_REMOVE(&capmts, capmt, capmt_link);
|
||||
capmt->capmt_running = 0;
|
||||
pthread_cond_broadcast(&capmt->capmt_cond);
|
||||
pthread_cond_signal(&capmt->capmt_cond);
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
tvh_write(capmt->capmt_pipe.wr, "", 1);
|
||||
pthread_join(capmt->capmt_tid, NULL);
|
||||
pthread_mutex_lock(&global_lock);
|
||||
tvhlog(LOG_INFO, "capmt", "mode %i %s %s port %i destroyed",
|
||||
capmt->capmt_oscam,
|
||||
capmt->capmt_oscam == CAPMT_OSCAM_TCP ? "IP address" : "sockfile",
|
||||
capmt->capmt_sockfile, capmt->capmt_port);
|
||||
capmt_flush_queue(capmt, 1);
|
||||
free(capmt->capmt_id);
|
||||
free(capmt->capmt_sockfile);
|
||||
free(capmt->capmt_comment);
|
||||
|
@ -2035,16 +2036,13 @@ capmt_init(void)
|
|||
void
|
||||
capmt_done(void)
|
||||
{
|
||||
capmt_t *capmt, *n;
|
||||
capmt_t *capmt;
|
||||
|
||||
for (capmt = TAILQ_FIRST(&capmts); capmt != NULL; capmt = n) {
|
||||
n = TAILQ_NEXT(capmt, capmt_link);
|
||||
pthread_mutex_lock(&global_lock);
|
||||
tvh_write(capmt->capmt_pipe.wr, "", 1);
|
||||
capmt_destroy(capmt);
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
}
|
||||
dtable_delete("capmt");
|
||||
pthread_mutex_lock(&global_lock);
|
||||
while ((capmt = TAILQ_FIRST(&capmts)) != NULL)
|
||||
capmt_destroy(capmt);
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
}
|
||||
|
||||
#else /* ENABLE_CAPMT */
|
||||
|
|
|
@ -1986,9 +1986,17 @@ cwc_service_start(service_t *t)
|
|||
static void
|
||||
cwc_destroy(cwc_t *cwc)
|
||||
{
|
||||
pthread_t tid;
|
||||
|
||||
lock_assert(&cwc_mutex);
|
||||
TAILQ_REMOVE(&cwcs, cwc, cwc_link);
|
||||
cwc->cwc_running = 0;
|
||||
pthread_cond_signal(&cwc->cwc_cond);
|
||||
tid = cwc->cwc_tid;
|
||||
pthread_mutex_unlock(&cwc_mutex);
|
||||
pthread_kill(tid, SIGTERM);
|
||||
pthread_join(tid, NULL);
|
||||
pthread_mutex_lock(&cwc_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2308,19 +2316,14 @@ void
|
|||
cwc_done(void)
|
||||
{
|
||||
cwc_t *cwc;
|
||||
pthread_t tid;
|
||||
|
||||
dtable_delete("cwc");
|
||||
pthread_mutex_lock(&global_lock);
|
||||
pthread_mutex_lock(&cwc_mutex);
|
||||
while ((cwc = TAILQ_FIRST(&cwcs)) != NULL) {
|
||||
tid = cwc->cwc_tid;
|
||||
while ((cwc = TAILQ_FIRST(&cwcs)) != NULL)
|
||||
cwc_destroy(cwc);
|
||||
pthread_mutex_unlock(&cwc_mutex);
|
||||
pthread_kill(tid, SIGTERM);
|
||||
pthread_join(tid, NULL);
|
||||
pthread_mutex_lock(&cwc_mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&cwc_mutex);
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue