aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-31 21:25:11 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-31 21:25:11 +0000
commit429708be61aa87849d22506b160268529e333966 (patch)
treec5e1072803ac13065b5b9f0d0e7e352f5cb1acf9
parent0c01638a1711f8e63655a564971e18db13a904f1 (diff)
Fix a bunch of places where pthread_attr_init() was called, but
pthread_attr_destroy() was not. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@53045 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_meetme.c1
-rw-r--r--apps/app_page.c1
-rw-r--r--apps/app_queue.c1
-rw-r--r--apps/app_rpt.c5
-rw-r--r--cdr.c1
-rw-r--r--channels/chan_h323.c2
-rw-r--r--channels/chan_iax2.c6
-rw-r--r--channels/chan_mgcp.c1
-rw-r--r--channels/chan_sip.c5
-rw-r--r--channels/chan_skinny.c1
-rw-r--r--channels/chan_zap.c17
-rw-r--r--manager.c1
-rw-r--r--pbx.c7
-rw-r--r--pbx/pbx_dundi.c6
-rw-r--r--pbx/pbx_spool.c2
15 files changed, 48 insertions, 9 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index a29289ed8..1efd4bbb4 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -862,6 +862,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
ast_verbose(VERBOSE_PREFIX_4 "Starting recording of MeetMe Conference %s into file %s.%s.\n",
conf->confno, conf->recordingfilename, conf->recordingformat);
ast_pthread_create(&conf->recordthread, &conf->attr, recordthread, conf);
+ pthread_attr_destroy(&conf->attr);
}
time(&user->jointime);
diff --git a/apps/app_page.c b/apps/app_page.c
index c1668cc7f..e57e5d051 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -135,6 +135,7 @@ static void launch_page(struct ast_channel *chan, const char *meetmeopts, const
ast_log(LOG_WARNING, "Unable to create paging thread: %s\n", strerror(errno));
free(cd);
}
+ pthread_attr_destroy(&attr);
}
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 64117322f..b6d809862 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -562,6 +562,7 @@ static int statechange_queue(const char *dev, int state, void *ign)
ast_log(LOG_WARNING, "Failed to create update thread!\n");
free(sc);
}
+ pthread_attr_destroy(&attr);
return 0;
}
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 913baaba8..a3f86c820 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -1521,6 +1521,7 @@ pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&tele->threadid,&attr,rpt_tele_thread,(void *) tele);
+ pthread_attr_destroy(&attr);
return;
}
@@ -2153,6 +2154,7 @@ static int function_autopatchup(struct rpt *myrpt, char *param, char *digitbuf,
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *) myrpt);
+ pthread_attr_destroy(&attr);
return DC_COMPLETE;
}
@@ -5239,6 +5241,7 @@ char cmd[MAXDTMF+1] = "";
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *)myrpt);
+ pthread_attr_destroy(&attr);
continue;
}
}
@@ -5781,6 +5784,7 @@ pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
+ pthread_attr_destroy(&attr);
}
usleep(500000);
for(;;)
@@ -5816,6 +5820,7 @@ pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
+ pthread_attr_destroy(&attr);
ast_log(LOG_WARNING, "rpt_thread restarted on node %s\n", rpt_vars[i].name);
}
diff --git a/cdr.c b/cdr.c
index f09d1e131..6838d619c 100644
--- a/cdr.c
+++ b/cdr.c
@@ -956,6 +956,7 @@ void ast_cdr_submit_batch(int shutdown)
if (option_debug)
ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n");
}
+ pthread_attr_destroy(&attr);
}
}
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 1b4a616a5..b2d4d8184 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -1642,9 +1642,11 @@ static int restart_monitor(void)
/* Start a new monitor */
if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
ast_mutex_unlock(&monlock);
+ pthread_attr_destroy(&attr);
ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
return -1;
}
+ pthread_attr_destroy(&attr);
}
ast_mutex_unlock(&monlock);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 76592002a..eca422dfb 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -6224,6 +6224,7 @@ static void spawn_dp_lookup(int callno, char *context, char *callednum, char *ca
if (ast_pthread_create(&newthread, &attr, dp_lookup_thread, dpr)) {
ast_log(LOG_WARNING, "Unable to start lookup thread!\n");
}
+ pthread_attr_destroy(&attr);
} else
ast_log(LOG_WARNING, "Out of memory!\n");
}
@@ -6304,8 +6305,11 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2)
memset(d, 0, sizeof(*d));
d->chan1 = chan1m;
d->chan2 = chan2m;
- if (!ast_pthread_create(&th, &attr, iax_park_thread, d))
+ if (!ast_pthread_create(&th, &attr, iax_park_thread, d)) {
+ pthread_attr_destroy(&attr);
return 0;
+ }
+ pthread_attr_destroy(&attr);
free(d);
}
return -1;
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 14b187426..de2d6a400 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -2963,6 +2963,7 @@ 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)
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a316065f2..5e1613275 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10402,8 +10402,11 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
copy_request(&d->req, req);
d->chan1 = chan1m;
d->chan2 = chan2m;
- if (!ast_pthread_create(&th, &attr, sip_park_thread, d))
+ if (!ast_pthread_create(&th, &attr, sip_park_thread, d)) {
+ pthread_attr_destroy(&attr);
return 0;
+ }
+ pthread_attr_destroy(&attr);
free(d);
}
return -1;
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index ca55bfcad..3cfd9d646 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2977,6 +2977,7 @@ static void *accept_thread(void *ignore)
ast_verbose("killing accept thread\n");
}
close(as);
+ pthread_attr_destroy(&attr);
return 0;
}
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index e8a885791..45ebb0c78 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -3668,9 +3668,6 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
pthread_attr_t attr;
struct ast_channel *chan;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
index = zt_get_index(ast, p, 0);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.datalen = 0;
@@ -4199,6 +4196,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (res)
ast_log(LOG_WARNING, "Unable to start dial recall tone on channel %d\n", p->channel);
p->owner = chan;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (!chan) {
ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", p->channel);
} else if (ast_pthread_create(&threadid, &attr, ss_thread, chan)) {
@@ -4212,7 +4211,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
/* Start music on hold if appropriate */
if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner))
ast_moh_start(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), NULL);
- }
+ }
+ pthread_attr_destroy(&attr);
}
} else {
/* Already have a 3 way call */
@@ -6579,6 +6579,7 @@ static int handle_init_event(struct zt_pvt *i, int event)
"interface %d\n", i->channel);
}
}
+ pthread_attr_destroy(&attr);
return 0;
}
@@ -6838,10 +6839,12 @@ static int restart_monitor(void)
if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
ast_mutex_unlock(&monlock);
ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
+ pthread_attr_destroy(&attr);
return -1;
}
}
ast_mutex_unlock(&monlock);
+ pthread_attr_destroy(&attr);
return 0;
}
@@ -8193,9 +8196,6 @@ static void *pri_dchannel(void *vpri)
char plancallingani[256];
char calledtonstr[10];
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
gettimeofday(&lastidle, NULL);
if (!ast_strlen_zero(pri->idledial) && !ast_strlen_zero(pri->idleext)) {
/* Need to do idle dialing, check to be sure though */
@@ -8683,6 +8683,8 @@ static void *pri_dchannel(void *vpri)
pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
ast_mutex_lock(&pri->lock);
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (c && !ast_pthread_create(&threadid, &attr, ss_thread, c)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Accepting overlap call from '%s' to '%s' on channel %d/%d, span %d\n",
@@ -8698,6 +8700,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->call = NULL;
}
}
+ pthread_attr_destroy(&attr);
} else {
ast_mutex_unlock(&pri->lock);
/* Release PRI lock while we create the channel */
diff --git a/manager.c b/manager.c
index 5254f7749..419d7cae4 100644
--- a/manager.c
+++ b/manager.c
@@ -1077,6 +1077,7 @@ static int action_originate(struct mansession *s, struct message *m)
} else {
res = 0;
}
+ pthread_attr_destroy(&attr);
}
} else if (!ast_strlen_zero(app)) {
res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
diff --git a/pbx.c b/pbx.c
index 5fae072ca..b126c3ddb 100644
--- a/pbx.c
+++ b/pbx.c
@@ -2541,8 +2541,10 @@ enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ast_pthread_create(&t, &attr, pbx_thread, c)) {
ast_log(LOG_WARNING, "Failed to create new channel thread\n");
+ pthread_attr_destroy(&attr);
return AST_PBX_FAILED;
}
+ pthread_attr_destroy(&attr);
return AST_PBX_SUCCESS;
}
@@ -5125,8 +5127,10 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
}
ast_hangup(chan);
res = -1;
+ pthread_attr_destroy(&attr);
goto outgoing_exten_cleanup;
}
+ pthread_attr_destroy(&attr);
res = 0;
}
outgoing_exten_cleanup:
@@ -5228,6 +5232,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
if (locked_channel)
*locked_channel = chan;
}
+ pthread_attr_destroy(&attr);
}
} else {
ast_log(LOG_ERROR, "Out of memory :(\n");
@@ -5290,11 +5295,13 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
ast_mutex_unlock(&chan->lock);
ast_hangup(chan);
res = -1;
+ pthread_attr_destroy(&attr);
goto outgoing_app_cleanup;
} else {
if (locked_channel)
*locked_channel = chan;
}
+ pthread_attr_destroy(&attr);
res = 0;
}
outgoing_app_cleanup:
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 8f0457296..8b87c8ec9 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -799,8 +799,10 @@ static int dundi_answer_entity(struct dundi_transaction *trans, struct dundi_ies
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));
@@ -1030,8 +1032,10 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
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));
@@ -1122,8 +1126,10 @@ static int dundi_answer_query(struct dundi_transaction *trans, struct dundi_ies
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 187beda1c..0fac2b1a9 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -295,6 +295,7 @@ static void launch_service(struct outgoing *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)
@@ -426,6 +427,7 @@ int load_module(void)
ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
return -1;
}
+ pthread_attr_destroy(&attr);
return 0;
}