From 937559ffd3ae80f7337a2292fcdcdec3a7f148a8 Mon Sep 17 00:00:00 2001 From: markster Date: Mon, 2 Feb 2004 00:46:59 +0000 Subject: Use better flags when starting MGCP threads (bug #598) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2106 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_mgcp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 38a5483ed..901f4132c 100755 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -2069,6 +2069,9 @@ 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) { @@ -2113,7 +2116,7 @@ static void handle_hd_hf(struct mgcp_subchannel *sub, char *ev) } c = mgcp_new(sub, AST_STATE_DOWN); if (c) { - if (pthread_create(&t, NULL, mgcp_ss, c)) { + if (pthread_create(&t, &attr, mgcp_ss, c)) { ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); ast_hangup(c); } @@ -2548,6 +2551,10 @@ static void *do_monitor(void *data) static int restart_monitor(void) { + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + /* If we're supposed to be stopped -- stay stopped */ if (monitor_thread == (pthread_t) -2) return 0; @@ -2565,7 +2572,7 @@ static int restart_monitor(void) pthread_kill(monitor_thread, SIGURG); } else { /* Start a new monitor */ - if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) { + if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) { ast_mutex_unlock(&monlock); ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); return -1; -- cgit v1.2.3