Skip to content

Commit

Permalink
create the mutex before creating threads (#1274)
Browse files Browse the repository at this point in the history
create the mutex before creating threads in collector_rrd.c
  • Loading branch information
anson-lo committed Feb 20, 2022
1 parent 42f832c commit 8076694
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cherokee/collector_rrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,17 @@ cherokee_collector_rrd_new (cherokee_collector_rrd_t **rrd,
*/
n->exiting = false;

re = pthread_create (&n->thread, NULL, rrd_thread_worker_func, n);

re = pthread_mutex_init (&n->mutex, NULL);
if (re != 0) {
LOG_ERROR (CHEROKEE_ERROR_COLLECTOR_NEW_THREAD, re);
LOG_ERROR (CHEROKEE_ERROR_COLLECTOR_NEW_MUTEX, re);
return ret_error;
}

re = pthread_mutex_init (&n->mutex, NULL);
re = pthread_create (&n->thread, NULL, rrd_thread_worker_func, n);
if (re != 0) {
LOG_ERROR (CHEROKEE_ERROR_COLLECTOR_NEW_MUTEX, re);
LOG_ERROR (CHEROKEE_ERROR_COLLECTOR_NEW_THREAD, re);
return ret_error;
}

/* Return obj
*/
*rrd = n;
Expand Down

0 comments on commit 8076694

Please sign in to comment.