[asterisk-commits] russell: branch 1.2 r53045 - in /branches/1.2: ./ apps/ channels/ pbx/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 31 14:25:12 MST 2007


Author: russell
Date: Wed Jan 31 15:25:11 2007
New Revision: 53045

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53045
Log:
Fix a bunch of places where pthread_attr_init() was called, but
pthread_attr_destroy() was not.

Modified:
    branches/1.2/apps/app_meetme.c
    branches/1.2/apps/app_page.c
    branches/1.2/apps/app_queue.c
    branches/1.2/apps/app_rpt.c
    branches/1.2/cdr.c
    branches/1.2/channels/chan_h323.c
    branches/1.2/channels/chan_iax2.c
    branches/1.2/channels/chan_mgcp.c
    branches/1.2/channels/chan_sip.c
    branches/1.2/channels/chan_skinny.c
    branches/1.2/channels/chan_zap.c
    branches/1.2/manager.c
    branches/1.2/pbx.c
    branches/1.2/pbx/pbx_dundi.c
    branches/1.2/pbx/pbx_spool.c

Modified: branches/1.2/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_meetme.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/apps/app_meetme.c (original)
+++ branches/1.2/apps/app_meetme.c Wed Jan 31 15:25:11 2007
@@ -862,6 +862,7 @@
 		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);

Modified: branches/1.2/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_page.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/apps/app_page.c (original)
+++ branches/1.2/apps/app_page.c Wed Jan 31 15:25:11 2007
@@ -135,6 +135,7 @@
 			ast_log(LOG_WARNING, "Unable to create paging thread: %s\n", strerror(errno));
 			free(cd);
 		}
+		pthread_attr_destroy(&attr);
 	}
 }
 

Modified: branches/1.2/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_queue.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/apps/app_queue.c (original)
+++ branches/1.2/apps/app_queue.c Wed Jan 31 15:25:11 2007
@@ -562,6 +562,7 @@
 		ast_log(LOG_WARNING, "Failed to create update thread!\n");
 		free(sc);
 	}
+	pthread_attr_destroy(&attr);
 
 	return 0;
 }

Modified: branches/1.2/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_rpt.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/apps/app_rpt.c (original)
+++ branches/1.2/apps/app_rpt.c Wed Jan 31 15:25:11 2007
@@ -1521,6 +1521,7 @@
         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 @@
 	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 @@
 					        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_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_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);
 			}
 

Modified: branches/1.2/cdr.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/cdr.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/cdr.c (original)
+++ branches/1.2/cdr.c Wed Jan 31 15:25:11 2007
@@ -956,6 +956,7 @@
 			if (option_debug)
 				ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n");
 		}
+		pthread_attr_destroy(&attr);
 	}
 }
 

Modified: branches/1.2/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_h323.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_h323.c (original)
+++ branches/1.2/channels/chan_h323.c Wed Jan 31 15:25:11 2007
@@ -1642,9 +1642,11 @@
                 /* 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);

Modified: branches/1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_iax2.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_iax2.c (original)
+++ branches/1.2/channels/chan_iax2.c Wed Jan 31 15:25:11 2007
@@ -6224,6 +6224,7 @@
 		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 @@
 		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;

Modified: branches/1.2/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_mgcp.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_mgcp.c (original)
+++ branches/1.2/channels/chan_mgcp.c Wed Jan 31 15:25:11 2007
@@ -2963,6 +2963,7 @@
 			/*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)

Modified: branches/1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_sip.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_sip.c (original)
+++ branches/1.2/channels/chan_sip.c Wed Jan 31 15:25:11 2007
@@ -10402,8 +10402,11 @@
 		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;

Modified: branches/1.2/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_skinny.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_skinny.c (original)
+++ branches/1.2/channels/chan_skinny.c Wed Jan 31 15:25:11 2007
@@ -2977,6 +2977,7 @@
 		ast_verbose("killing accept thread\n");
 	}
 	close(as);
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 

Modified: branches/1.2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_zap.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/channels/chan_zap.c (original)
+++ branches/1.2/channels/chan_zap.c Wed Jan 31 15:25:11 2007
@@ -3667,9 +3667,6 @@
 	pthread_t threadid;
 	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;
@@ -4199,6 +4196,8 @@
 						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 @@
 							/* 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 @@
 				"interface %d\n", i->channel);
 		}
 	}
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 
@@ -6838,10 +6839,12 @@
 		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 @@
 	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 @@
 								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 @@
 									pri->pvts[chanpos]->call = NULL;
 								}
 							}
+							pthread_attr_destroy(&attr);
 						} else  {
 							ast_mutex_unlock(&pri->lock);
 							/* Release PRI lock while we create the channel */

Modified: branches/1.2/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/manager.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/manager.c (original)
+++ branches/1.2/manager.c Wed Jan 31 15:25:11 2007
@@ -1077,6 +1077,7 @@
 			} 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);

Modified: branches/1.2/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/pbx.c (original)
+++ branches/1.2/pbx.c Wed Jan 31 15:25:11 2007
@@ -2541,8 +2541,10 @@
 	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 @@
 			}
 			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 @@
 							if (locked_channel) 
 								*locked_channel = chan;
 						}
+						pthread_attr_destroy(&attr);
 					}
 				} else {
 					ast_log(LOG_ERROR, "Out of memory :(\n");
@@ -5290,11 +5295,13 @@
 				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:

Modified: branches/1.2/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx/pbx_dundi.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/pbx/pbx_dundi.c (original)
+++ branches/1.2/pbx/pbx_dundi.c Wed Jan 31 15:25:11 2007
@@ -799,8 +799,10 @@
 			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 @@
 			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 @@
 			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));

Modified: branches/1.2/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx/pbx_spool.c?view=diff&rev=53045&r1=53044&r2=53045
==============================================================================
--- branches/1.2/pbx/pbx_spool.c (original)
+++ branches/1.2/pbx/pbx_spool.c Wed Jan 31 15:25:11 2007
@@ -295,6 +295,7 @@
 		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 @@
 		ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
 		return -1;
 	}
+	pthread_attr_destroy(&attr);
 	return 0;
 }
 



More information about the asterisk-commits mailing list