Skip to content

Commit

Permalink
Merge pull request FRRouting#930 from qlyoung/fix-masters-list-reachable
Browse files Browse the repository at this point in the history
lib: fix still reachable linked list in thread.c
  • Loading branch information
louberger authored Aug 8, 2017
2 parents d3d9c86 + eff09c6 commit 11f3bfd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 11f3bfd

Please sign in to comment.