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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 6 12:48:58 CST 2008


Author: jpeeler
Date: Thu Nov  6 12:48:57 2008
New Revision: 155007

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155007
Log:
change announcelist to nolock and use standalone mutex

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=155007&r1=155006&r2=155007
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Thu Nov  6 12:48:57 2008
@@ -363,7 +363,8 @@
 	AST_LIST_HEAD_NOLOCK(, ast_conf_user) userlist;
 	AST_LIST_ENTRY(ast_conference) list;
 	ast_cond_t announcelist_addition;
-	AST_LIST_HEAD(, announce_listitem) announcelist;
+	AST_LIST_HEAD_NOLOCK(, announce_listitem) announcelist;
+	ast_mutex_t announcelistlock;
 };
 
 static AST_LIST_HEAD_STATIC(confs, ast_conference);
@@ -784,7 +785,7 @@
 	ast_mutex_init(&cnf->recordthreadlock);
 	cnf->announcethread = AST_PTHREADT_NULL;
 	ast_mutex_init(&cnf->announcethreadlock);
-	AST_LIST_HEAD_INIT(&cnf->announcelist);
+	ast_mutex_init(&cnf->announcelistlock);
 	ast_copy_string(cnf->confno, confno, sizeof(cnf->confno));
 	ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
 	ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
@@ -1279,17 +1280,17 @@
 			ast_translator_free_path(conf->transpath[x]);
 	}
 	if (conf->announcethread != AST_PTHREADT_NULL) {
-		AST_LIST_LOCK(&conf->announcelist);
+		ast_mutex_lock(&conf->announcelistlock);
 		conf->announcethread_stop = 1;
 		ast_softhangup(conf->chan, AST_SOFTHANGUP_EXPLICIT);
 		ast_cond_signal(&conf->announcelist_addition);
-		AST_LIST_UNLOCK(&conf->announcelist);
+		ast_mutex_unlock(&conf->announcelistlock);
 		pthread_join(conf->announcethread, NULL);
 		while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) {
 			ast_filedelete(item->namerecloc, NULL);
 			ast_free(item);
 		}
-		AST_LIST_HEAD_DESTROY(&conf->announcelist);
+		ast_mutex_destroy(&conf->announcelistlock);
 	}
 	if (conf->origframe)
 		ast_frfree(conf->origframe);
@@ -1427,9 +1428,9 @@
 static int announcement_played(struct ast_conference *conf, struct ast_channel *chan)
 {
 	struct announce_listitem *item;
-	AST_LIST_LOCK(&conf->announcelist);
+	ast_mutex_lock(&conf->announcelistlock);
 	if (AST_LIST_EMPTY(&conf->announcelist)) {
-		AST_LIST_UNLOCK(&conf->announcelist);
+		ast_mutex_unlock(&conf->announcelistlock);
 	ast_log(LOG_NOTICE, "jpeeler: list was empty\n");
 		return 0;
 	}
@@ -1438,7 +1439,7 @@
 	while (item) {
 	ast_log(LOG_NOTICE, "jpeeler: checking for match in %s\n", item->channame);
 		if (!strcmp(item->channame, chan->name)) {
-			AST_LIST_UNLOCK(&conf->announcelist);
+			ast_mutex_unlock(&conf->announcelistlock);
 	ast_log(LOG_NOTICE, "jpeeler: announcement not played yet\n");
 			return 1;
 		}
@@ -1446,7 +1447,7 @@
 	}
 
 	ast_log(LOG_NOTICE, "jpeeler: announcement not found\n");
-	AST_LIST_UNLOCK(&conf->announcelist);
+	ast_mutex_unlock(&conf->announcelistlock);
 	return 0;
 }
 
@@ -1458,15 +1459,15 @@
 	char filename[PATH_MAX] = "";
 
 	while (!conf->announcethread_stop) {
-		AST_LIST_LOCK(&conf->announcelist);
+		ast_mutex_lock(&conf->announcelistlock);
 		if (conf->announcethread_stop) {
-			AST_LIST_UNLOCK(&conf->announcelist);
+			ast_mutex_unlock(&conf->announcelistlock);
 			return NULL;
 		}
 		if (AST_LIST_EMPTY(&conf->announcelist))
-			ast_cond_wait(&conf->announcelist_addition, &conf->announcelist.lock);
+			ast_cond_wait(&conf->announcelist_addition, &conf->announcelistlock);
 		next = AST_LIST_FIRST(&conf->announcelist);
-		AST_LIST_UNLOCK(&conf->announcelist);
+		ast_mutex_unlock(&conf->announcelistlock);
 		if (conf->announcethread_stop)
 			return NULL;
 
@@ -1490,14 +1491,10 @@
 				}
 			}
 			next = AST_LIST_NEXT(current, entry);
-			AST_LIST_LOCK(&conf->announcelist);
-			if (conf->announcethread_stop) {
-				AST_LIST_UNLOCK(&conf->announcelist);
-				return NULL;
-			}
+			ast_mutex_lock(&conf->announcelistlock);
 			AST_LIST_REMOVE_HEAD(&conf->announcelist, entry);
 			free(current);
-			AST_LIST_UNLOCK(&conf->announcelist);
+			ast_mutex_unlock(&conf->announcelistlock);
 		}
 	}
 
@@ -1819,10 +1816,10 @@
 		item->confchan = conf->chan;
 		item->confusers = conf->users;
 		item->announcetype = CONF_HASJOIN;
-		AST_LIST_LOCK(&conf->announcelist);
+		ast_mutex_lock(&conf->announcelistlock);
 		AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry);
 		ast_cond_signal(&conf->announcelist_addition);
-		AST_LIST_UNLOCK(&conf->announcelist);
+		ast_mutex_unlock(&conf->announcelistlock);
 	}
 
 	if (confflags & CONFFLAG_WAITMARKED && !conf->markedusers)
@@ -2423,10 +2420,10 @@
 		item->confchan = conf->chan;
 		item->confusers = conf->users;
 		item->announcetype = CONF_HASLEFT;
-		AST_LIST_LOCK(&conf->announcelist);
+		ast_mutex_lock(&conf->announcelistlock);
 		AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry);
 		ast_cond_signal(&conf->announcelist_addition);
-		AST_LIST_UNLOCK(&conf->announcelist);
+		ast_mutex_unlock(&conf->announcelistlock);
 	} else if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users == 1) {
 		/* Last person is leaving, so no reason to try and announce, but should delete the name recording */
 		ast_filedelete(user->namerecloc, NULL);




More information about the asterisk-commits mailing list