diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-08-08 12:54:28 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-08-08 12:54:28 -0400 |
| commit | eff09c66a4214cb9407a1f5906347a1c2143f167 (patch) | |
| tree | d86be9b68cc685b5591e81854256faf2b7595be5 /lib/thread.c | |
| parent | d1783281630a888a61a24299ae73c973588ff481 (diff) | |
lib: fix still reachable linked list in thread.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/thread.c b/lib/thread.c index fd36eaf388..4a5c61d036 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -340,9 +340,6 @@ static void cancelreq_del(void *cr) /* initializer, only ever called once */ static void initializer() { - if (!masters) - masters = list_new(); - pthread_key_create(&thread_current, NULL); } @@ -415,9 +412,12 @@ struct thread_master *thread_master_create(const char *name) rv->handler.copy = XCALLOC(MTYPE_THREAD_MASTER, sizeof(struct pollfd) * rv->handler.pfdsize); - /* add to list */ + /* add to list of threadmasters */ pthread_mutex_lock(&masters_mtx); { + if (!masters) + masters = list_new(); + listnode_add(masters, rv); } pthread_mutex_unlock(&masters_mtx); @@ -551,6 +551,10 @@ void thread_master_free(struct thread_master *m) pthread_mutex_lock(&masters_mtx); { listnode_delete(masters, m); + if (masters->count == 0) { + list_free (masters); + masters = NULL; + } } pthread_mutex_unlock(&masters_mtx); |
