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
This commit is contained in:
Russell Bryant
2007-05-24 18:30:19 +00:00
parent bcd2bd8294
commit 4b3a3fb14c
18 changed files with 80 additions and 189 deletions

View File

@@ -2956,9 +2956,6 @@ static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev)
struct mgcp_endpoint *p = sub->parent;
struct ast_channel *c;
pthread_t t;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* Off hook / answer */
if (sub->outgoing) {
@@ -3006,7 +3003,7 @@ static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev)
}
c = mgcp_new(sub, AST_STATE_DOWN);
if (c) {
if (ast_pthread_create(&t, &attr, mgcp_ss, c)) {
if (ast_pthread_create_detached(&t, NULL, mgcp_ss, c)) {
ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno));
ast_hangup(c);
}
@@ -3034,7 +3031,6 @@ static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev)
/*ast_queue_control(sub->owner, AST_CONTROL_ANSWER);*/
}
}
pthread_attr_destroy(&attr);
}
static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req, struct sockaddr_in *sin)