diff options
Diffstat (limited to 'pbx')
-rw-r--r-- | pbx/pbx_dundi.c | 23 | ||||
-rw-r--r-- | pbx/pbx_spool.c | 15 |
2 files changed, 10 insertions, 28 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 433558dbb..685711170 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -771,7 +771,7 @@ static int dundi_answer_entity(struct dundi_transaction *trans, struct dundi_ies char eid_str[20]; char *s; pthread_t lookupthread; - pthread_attr_t attr; + if (ies->eidcount > 1) { /* Since it is a requirement that the first EID is the authenticating host and the last EID is the root, it is permissible that the first and last EID @@ -798,20 +798,17 @@ static int dundi_answer_entity(struct dundi_transaction *trans, struct dundi_ies } if (option_debug) ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context); - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + trans->thread = 1; - if (ast_pthread_create(&lookupthread, &attr, dundi_query_thread, st)) { + if (ast_pthread_create_detached(&lookupthread, NULL, dundi_query_thread, st)) { trans->thread = 0; ast_log(LOG_WARNING, "Unable to create thread!\n"); free(st); memset(&ied, 0, sizeof(ied)); dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads"); dundi_send(trans, DUNDI_COMMAND_EIDRESPONSE, 0, 1, &ied); - pthread_attr_destroy(&attr); return -1; } - pthread_attr_destroy(&attr); } else { ast_log(LOG_WARNING, "Out of memory!\n"); memset(&ied, 0, sizeof(ied)); @@ -916,7 +913,6 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies int skipfirst = 0; pthread_t lookupthread; - pthread_attr_t attr; memset(&dr2, 0, sizeof(dr2)); memset(&dr, 0, sizeof(dr)); @@ -1029,20 +1025,16 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies st->nummaps = mapcount; if (option_debug) ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context); - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); trans->thread = 1; - if (ast_pthread_create(&lookupthread, &attr, dundi_precache_thread, st)) { + if (ast_pthread_create_detached(&lookupthread, NULL, dundi_precache_thread, st)) { trans->thread = 0; ast_log(LOG_WARNING, "Unable to create thread!\n"); free(st); memset(&ied, 0, sizeof(ied)); dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads"); dundi_send(trans, DUNDI_COMMAND_PRECACHERP, 0, 1, &ied); - pthread_attr_destroy(&attr); return -1; } - pthread_attr_destroy(&attr); } else { ast_log(LOG_WARNING, "Out of memory!\n"); memset(&ied, 0, sizeof(ied)); @@ -1065,7 +1057,6 @@ static int dundi_answer_query(struct dundi_transaction *trans, struct dundi_ies int skipfirst = 0; pthread_t lookupthread; - pthread_attr_t attr; totallen = sizeof(struct dundi_query_state); /* Count matching map entries */ AST_LIST_TRAVERSE(&mappings, cur, list) { @@ -1118,20 +1109,16 @@ static int dundi_answer_query(struct dundi_transaction *trans, struct dundi_ies st->nummaps = mapcount; if (option_debug) ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context); - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); trans->thread = 1; - if (ast_pthread_create(&lookupthread, &attr, dundi_lookup_thread, st)) { + if (ast_pthread_create_detached(&lookupthread, NULL, dundi_lookup_thread, st)) { trans->thread = 0; ast_log(LOG_WARNING, "Unable to create thread!\n"); free(st); memset(&ied, 0, sizeof(ied)); dundi_ie_append_cause(&ied, DUNDI_IE_CAUSE, DUNDI_CAUSE_GENERAL, "Out of threads"); dundi_send(trans, DUNDI_COMMAND_DPRESPONSE, 0, 1, &ied); - pthread_attr_destroy(&attr); return -1; } - pthread_attr_destroy(&attr); } else { ast_log(LOG_WARNING, "Out of memory!\n"); memset(&ied, 0, sizeof(ied)); 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; } |