mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 14:58:25 +00:00
Create outgoing threads detached (bug #391)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
12
pbx.c
12
pbx.c
@@ -3790,6 +3790,8 @@ int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
char *var, *tmp;
|
char *var, *tmp;
|
||||||
struct outgoing_helper oh;
|
struct outgoing_helper oh;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
LOAD_OH(oh);
|
LOAD_OH(oh);
|
||||||
chan = __ast_request_and_dial(type, format, data, timeout, reason, callerid, &oh);
|
chan = __ast_request_and_dial(type, format, data, timeout, reason, callerid, &oh);
|
||||||
@@ -3854,7 +3856,9 @@ int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char
|
|||||||
strncpy(as->exten, exten, sizeof(as->exten) - 1);
|
strncpy(as->exten, exten, sizeof(as->exten) - 1);
|
||||||
as->priority = priority;
|
as->priority = priority;
|
||||||
as->timeout = timeout;
|
as->timeout = timeout;
|
||||||
if (pthread_create(&as->p, NULL, async_wait, as)) {
|
pthread_attr_init(&attr);
|
||||||
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
if (pthread_create(&as->p, &attr, async_wait, as)) {
|
||||||
ast_log(LOG_WARNING, "Failed to start async wait\n");
|
ast_log(LOG_WARNING, "Failed to start async wait\n");
|
||||||
free(as);
|
free(as);
|
||||||
ast_hangup(chan);
|
ast_hangup(chan);
|
||||||
@@ -3895,6 +3899,8 @@ int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *
|
|||||||
struct app_tmp *tmp;
|
struct app_tmp *tmp;
|
||||||
char *var, *vartmp;
|
char *var, *vartmp;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
|
||||||
if (!app || !strlen(app))
|
if (!app || !strlen(app))
|
||||||
return -1;
|
return -1;
|
||||||
if (sync) {
|
if (sync) {
|
||||||
@@ -3917,7 +3923,9 @@ int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *
|
|||||||
if (sync > 1) {
|
if (sync > 1) {
|
||||||
ast_pbx_run_app(tmp);
|
ast_pbx_run_app(tmp);
|
||||||
} else {
|
} else {
|
||||||
if (pthread_create(&tmp->t, NULL, ast_pbx_run_app, tmp)) {
|
pthread_attr_init(&attr);
|
||||||
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
if (pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
|
||||||
ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
|
||||||
free(tmp);
|
free(tmp);
|
||||||
ast_hangup(chan);
|
ast_hangup(chan);
|
||||||
|
|||||||
Reference in New Issue
Block a user