diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-24 18:30:19 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-24 18:30:19 +0000 |
commit | a42bc96f14e6c4c6c8fe8e7c743df555036e885b (patch) | |
tree | 86895556d8f221a39105f4398a54d612fbbd3da8 /main/asterisk.c | |
parent | f97bf5fd4d30bd179aac274961e7695ddc60e165 (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@65968 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index e95736061..a2f9efb33 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -932,9 +932,6 @@ static void *listener(void *unused) int x; int flags; struct pollfd fds[1]; - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for (;;) { if (ast_socket < 0) return NULL; @@ -966,7 +963,7 @@ static void *listener(void *unused) fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK); consoles[x].fd = s; consoles[x].mute = ast_opt_mute; - if (ast_pthread_create_background(&consoles[x].t, &attr, netconsole, &consoles[x])) { + if (ast_pthread_create_detached_background(&consoles[x].t, NULL, netconsole, &consoles[x])) { ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno)); close(consoles[x].p[0]); close(consoles[x].p[1]); @@ -3029,13 +3026,9 @@ int main(int argc, char *argv[]) /* Console stuff now... */ /* Register our quit function */ char title[256]; - pthread_attr_t attr; pthread_t dont_care; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - ast_pthread_create(&dont_care, &attr, monitor_sig_flags, NULL); - pthread_attr_destroy(&attr); + ast_pthread_create_detached(&dont_care, NULL, monitor_sig_flags, NULL); set_icon("Asterisk"); snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %ld)", hostname, (long)ast_mainpid); |