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 /pbx/pbx_spool.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 'pbx/pbx_spool.c')
-rw-r--r-- | pbx/pbx_spool.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c index e84ebaaf5..aaefef56d 100644 --- a/pbx/pbx_spool.c +++ b/pbx/pbx_spool.c @@ -359,15 +359,12 @@ static void *attempt_thread(void *data) static void launch_service(struct outgoing *o) { pthread_t t; - pthread_attr_t attr; int ret; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if ((ret = ast_pthread_create(&t,&attr,attempt_thread, o)) != 0) { + + if ((ret = ast_pthread_create_detached(&t, NULL, attempt_thread, o))) { ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret); free_outgoing(o); } - pthread_attr_destroy(&attr); } static int scan_service(char *fn, time_t now, time_t atime) @@ -486,7 +483,6 @@ static int unload_module(void) static int load_module(void) { pthread_t thread; - pthread_attr_t attr; int ret; snprintf(qdir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing"); if (mkdir(qdir, 0700) && (errno != EEXIST)) { @@ -494,13 +490,12 @@ static int load_module(void) return 0; } snprintf(qdonedir, sizeof(qdir), "%s/%s", ast_config_AST_SPOOL_DIR, "outgoing_done"); - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if ((ret = ast_pthread_create_background(&thread,&attr,scan_thread, NULL)) != 0) { + + if ((ret = ast_pthread_create_detached_background(&thread, NULL, scan_thread, NULL))) { ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret); return -1; } - pthread_attr_destroy(&attr); + return 0; } |