[asterisk-commits] jpeeler: branch jpeeler/bug13173 r150801 - /team/jpeeler/bug13173/apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 17 19:31:49 CDT 2008


Author: jpeeler
Date: Fri Oct 17 19:31:48 2008
New Revision: 150801

URL: http://svn.digium.com/view/asterisk?view=rev&rev=150801
Log:
check point, there is a memory leak that needs to be fixed still

Modified:
    team/jpeeler/bug13173/apps/app_meetme.c

Modified: team/jpeeler/bug13173/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/bug13173/apps/app_meetme.c?view=diff&rev=150801&r1=150800&r2=150801
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Fri Oct 17 19:31:48 2008
@@ -1247,6 +1247,7 @@
 static int conf_free(struct ast_conference *conf)
 {
 	int x;
+	struct announce_listitem *item;
 	
 	AST_LIST_REMOVE(&confs, conf, list);
 
@@ -1268,6 +1269,15 @@
 		if (conf->transpath[x])
 			ast_translator_free_path(conf->transpath[x]);
 	}
+	if (conf->announcethread != AST_PTHREADT_NULL) {
+		pthread_cancel(conf->announcethread);
+		pthread_join(conf->announcethread, NULL);
+		ast_clear_flag(conf->chan, AST_FLAG_BLOCKING);
+		while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, list))) {
+	ast_log(LOG_NOTICE, "freeing item\n");
+			free(item);
+		}
+	}
 	if (conf->origframe)
 		ast_frfree(conf->origframe);
 	if (conf->lchan)
@@ -1281,9 +1291,7 @@
 	ast_mutex_destroy(&conf->listenlock);
 	ast_mutex_destroy(&conf->recordthreadlock);
 	ast_mutex_destroy(&conf->announcethreadlock);
-	if (conf->announcethread != AST_PTHREADT_NULL) {
-		pthread_cancel(conf->announcethread);
-	}
+	
 	free(conf);
 
 	return 0;
@@ -1391,7 +1399,7 @@
 static void *announce_thread(void *data)
 {
 	struct announce_listitem *next, *current;
-	struct ast_conference *conf = (struct ast_conference *) data;
+	struct ast_conference *conf = data;
 
 	for (;;) {
 		AST_LIST_LOCK(&conf->announcelist);
@@ -1513,10 +1521,11 @@
 
 	ast_mutex_lock(&conf->announcethreadlock);
 	if ((conf->announcethread == AST_PTHREADT_NULL) && !(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
-		pthread_attr_init(&conf->attr);
-		pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED);
-		ast_pthread_create_background(&conf->announcethread, &conf->attr, announce_thread, conf);
-		pthread_attr_destroy(&conf->attr);
+		//pthread_attr_init(&conf->attr);
+		//pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED);
+		//ast_pthread_create_background(&conf->announcethread, &conf->attr, announce_thread, conf);
+		//pthread_attr_destroy(&conf->attr);
+		ast_pthread_create(&conf->announcethread, NULL, announce_thread, conf);
 	}
 	ast_mutex_unlock(&conf->announcethreadlock);
 
@@ -2324,6 +2333,7 @@
 
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
 		struct announce_listitem *item = ast_calloc(1, sizeof(*item));
+ast_log(LOG_NOTICE, "adding item\n");
 		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
 		ast_copy_string(item->language, chan->language, sizeof(item->language));
 		item->confchan = conf->chan;




More information about the asterisk-commits mailing list