mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Add a new API call for creating detached threads. Then, go replace all of the
places in the code where the same block of code for creating detached threads was replicated. (patch from bbryant) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@65968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2601,7 +2601,6 @@ restartsearch:
|
||||
|
||||
static int restart_monitor(void)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
/* If we're supposed to be stopped -- stay stopped */
|
||||
if (ast_mutex_lock(&monlock)) {
|
||||
ast_log(LOG_WARNING, "Unable to lock monitor\n");
|
||||
@@ -2620,17 +2619,13 @@ static int restart_monitor(void)
|
||||
/* Wake up the thread */
|
||||
pthread_kill(monitor_thread, SIGURG);
|
||||
} else {
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
/* Start a new monitor */
|
||||
if (ast_pthread_create_background(&monitor_thread, &attr, do_monitor, NULL) < 0) {
|
||||
if (ast_pthread_create_detached_background(&monitor_thread, NULL, do_monitor, NULL) < 0) {
|
||||
monitor_thread = AST_PTHREADT_NULL;
|
||||
ast_mutex_unlock(&monlock);
|
||||
ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
|
||||
pthread_attr_destroy(&attr);
|
||||
return -1;
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
ast_mutex_unlock(&monlock);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user