summaryrefslogtreecommitdiff
path: root/pbx/pbx_spool.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-05-24 18:30:19 +0000
committerRussell Bryant <russell@russellbryant.com>2007-05-24 18:30:19 +0000
commit4b3a3fb14c298512ef69e17a710e210de14914fb (patch)
tree86895556d8f221a39105f4398a54d612fbbd3da8 /pbx/pbx_spool.c
parentbcd2bd8294408ca2f432747ef2e3073edecec4c1 (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: https://origsvn.digium.com/svn/asterisk/trunk@65968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx/pbx_spool.c')
-rw-r--r--pbx/pbx_spool.c15
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;
}