diff options
| author | Lou Berger <lberger@labn.net> | 2017-08-08 13:58:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-08 13:58:06 -0400 |
| commit | 11f3bfdd71f9ccef52ddb6bc349b0554fd18c7ff (patch) | |
| tree | 242ec82063922040083714bb0872110a8460ff49 /lib/thread.c | |
| parent | d3d9c86f540ce6b7a8e048519085c9c60d075c15 (diff) | |
| parent | eff09c66a4214cb9407a1f5906347a1c2143f167 (diff) | |
Merge pull request #930 from qlyoung/fix-masters-list-reachable
lib: fix still reachable linked list in thread.c
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); |
