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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 11 12:54:14 CST 2008


Author: jpeeler
Date: Tue Nov 11 12:54:14 2008
New Revision: 155982

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155982
Log:
make a local list in announce thread to simply while loop

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=155982&r1=155981&r2=155982
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Tue Nov 11 12:54:14 2008
@@ -1256,6 +1256,7 @@
 static int conf_free(struct ast_conference *conf)
 {
 	int x;
+	struct announce_listitem *item;
 	
 	AST_LIST_REMOVE(&confs, conf, list);
 
@@ -1280,10 +1281,18 @@
 	if (conf->announcethread != AST_PTHREADT_NULL) {
 		ast_mutex_lock(&conf->announcelistlock);
 		conf->announcethread_stop = 1;
+ast_log(LOG_NOTICE, "jpeeler: announce thread marked to be stopped\n");
 		ast_softhangup(conf->chan, AST_SOFTHANGUP_EXPLICIT);
 		ast_cond_signal(&conf->announcelist_addition);
 		ast_mutex_unlock(&conf->announcelistlock);
 		pthread_join(conf->announcethread, NULL);
+ast_log(LOG_NOTICE, "jpeeler: announce thread stopped\n");
+	
+		while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) {
+			ast_log(LOG_NOTICE, "jpeeler: deleting %s from announcelist\n", item->namerecloc);
+			ast_filedelete(item->namerecloc, NULL);
+			ao2_ref(item, -1);
+		}
 		ast_mutex_destroy(&conf->announcelistlock);
 	}
 	if (conf->origframe)
@@ -1420,10 +1429,12 @@
 
 static void *announce_thread(void *data)
 {
-	struct announce_listitem *next, *current;
+	struct announce_listitem *current;
 	struct ast_conference *conf = data;
 	int res;
 	char filename[PATH_MAX] = "";
+	AST_LIST_HEAD_NOLOCK(, announce_listitem) local_list;
+	AST_LIST_HEAD_INIT_NOLOCK(&local_list);
 
 	while (!conf->announcethread_stop) {
 		ast_mutex_lock(&conf->announcelistlock);
@@ -1433,13 +1444,16 @@
 		}
 		if (AST_LIST_EMPTY(&conf->announcelist))
 			ast_cond_wait(&conf->announcelist_addition, &conf->announcelistlock);
-		next = AST_LIST_FIRST(&conf->announcelist);
+
+		AST_LIST_APPEND_LIST(&local_list, &conf->announcelist, entry);
+		AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist);
+
 		ast_mutex_unlock(&conf->announcelistlock);
 		if (conf->announcethread_stop) {
 			goto finish;
 		}
 
-		while ((current = next) && !conf->announcethread_stop) {
+		while (!conf->announcethread_stop && (current = AST_LIST_REMOVE_HEAD(&local_list, entry))) {
 			ast_log(LOG_DEBUG, "About to play %s\n", current->namerecloc);
 			if (ast_fileexists(current->namerecloc, NULL, NULL)) {
 				if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) {
@@ -1458,16 +1472,12 @@
 					ast_log(LOG_DEBUG, "jpeeler type= %d\n", current->announcetype);
 				}
 			}
-			next = AST_LIST_NEXT(current, entry);
-			ast_mutex_lock(&conf->announcelistlock);
-			AST_LIST_REMOVE_HEAD(&conf->announcelist, entry);
 			ao2_ref(current, -1);
-			ast_mutex_unlock(&conf->announcelistlock);
 		}
 	}
 
 finish:
-	while ((current = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) {
+	while ((current = AST_LIST_REMOVE_HEAD(&local_list, entry))) {
 		ast_log(LOG_DEBUG, "jpeeler: deleting %s\n", current->namerecloc);
 		ast_filedelete(current->namerecloc, NULL);
 		ao2_ref(current, -1);




More information about the asterisk-commits mailing list