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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 7 16:06:06 CST 2008


Author: jpeeler
Date: Fri Nov  7 16:06:05 2008
New Revision: 155397

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155397
Log:
fix some stuff before I break it again

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=155397&r1=155396&r2=155397
==============================================================================
--- team/jpeeler/bug13173/apps/app_meetme.c (original)
+++ team/jpeeler/bug13173/apps/app_meetme.c Fri Nov  7 16:06:05 2008
@@ -351,7 +351,7 @@
 	ast_mutex_t recordthreadlock;		/*!< control threads trying to start recordthread */
 	pthread_t announcethread;
 	ast_mutex_t announcethreadlock;
-	int announcethread_stop:1;
+	unsigned int announcethread_stop:1;
 	pthread_attr_t attr;                    /*!< thread attribute */
 	const char *recordingfilename;          /*!< Filename to record the Conference into */
 	const char *recordingformat;            /*!< Format to record the Conference in */
@@ -1286,6 +1286,7 @@
 		ast_mutex_unlock(&conf->announcelistlock);
 		pthread_join(conf->announcethread, NULL);
 		while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) {
+				ast_log(LOG_DEBUG, "jpeeler: deleting %s\n", item->namerecloc);
 			ast_filedelete(item->namerecloc, NULL);
 			ast_free(item);
 		}
@@ -1427,6 +1428,7 @@
 static int announcement_played(struct ast_conference *conf, struct ast_channel *chan)
 {
 	struct announce_listitem *item;
+	int ret = 0;
 	ast_mutex_lock(&conf->announcelistlock);
 	if (AST_LIST_EMPTY(&conf->announcelist)) {
 		ast_mutex_unlock(&conf->announcelistlock);
@@ -1434,20 +1436,20 @@
 		return 0;
 	}
 
-	item = AST_LIST_FIRST(&conf->announcelist);
-	while (item) {
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&conf->announcelist, item, entry) {
 	ast_log(LOG_NOTICE, "jpeeler: checking for match in %s\n", item->channame);
 		if (!strcmp(item->channame, chan->name)) {
-			ast_mutex_unlock(&conf->announcelistlock);
 	ast_log(LOG_NOTICE, "jpeeler: announcement not played yet\n");
-			return 1;
+			ret = 1;
+			break;
 		}
 		item = AST_LIST_NEXT(item, entry);
 	}
+	AST_LIST_TRAVERSE_SAFE_END;
 
 	ast_log(LOG_NOTICE, "jpeeler: announcement not found\n");
 	ast_mutex_unlock(&conf->announcelistlock);
-	return 0;
+	return ret;
 }
 
 static void *announce_thread(void *data)
@@ -1471,7 +1473,7 @@
 			return NULL;
 		}
 
-		while ((current = next)) {
+		while ((current = next) && !conf->announcethread_stop) {
 			ast_log(LOG_DEBUG, "About to play %s on behalf of %s\n", current->namerecloc, current->channame);
 			if (ast_fileexists(current->namerecloc, NULL, NULL)) {
 				if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) {
@@ -1493,7 +1495,7 @@
 			next = AST_LIST_NEXT(current, entry);
 			ast_mutex_lock(&conf->announcelistlock);
 			AST_LIST_REMOVE_HEAD(&conf->announcelist, entry);
-			free(current);
+			ast_free(current);
 			ast_mutex_unlock(&conf->announcelistlock);
 		}
 	}
@@ -1599,6 +1601,7 @@
 		//ast_pthread_create_background(&conf->announcethread, &conf->attr, announce_thread, conf);
 		//pthread_attr_destroy(&conf->attr);
 		ast_mutex_init(&conf->announcelistlock);
+		AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist);
 		ast_pthread_create_background(&conf->announcethread, NULL, announce_thread, conf);
 	}
 	ast_mutex_unlock(&conf->announcethreadlock);
@@ -1807,10 +1810,12 @@
 	ztc.chan = 0;	
 	ztc.confno = conf->zapconf;
 
-	ast_mutex_lock(&conf->playlock);
+	//ast_mutex_lock(&conf->playlock);
 
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) {
-		struct announce_listitem *item = ast_calloc(1, sizeof(*item));
+		struct announce_listitem *item;
+		if (!(item = ast_calloc(1, sizeof(*item))))
+			return -1;
 		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
 		ast_copy_string(item->language, chan->language, sizeof(item->language));
 		ast_copy_string(item->channame, chan->name, sizeof(item->channame));
@@ -1839,7 +1844,7 @@
 	if (ioctl(fd, DAHDI_SETCONF, &ztc)) {
 		ast_log(LOG_WARNING, "Error setting conference\n");
 		close(fd);
-		ast_mutex_unlock(&conf->playlock);
+		//ast_mutex_unlock(&conf->playlock);
 		goto outrun;
 	}
 	ast_log(LOG_DEBUG, "Placed channel %s in %s conf %d\n", chan->name, dahdi_chan_name, conf->zapconf);
@@ -1861,7 +1866,7 @@
 				conf_play(chan, conf, ENTER);
 	}
 
-	ast_mutex_unlock(&conf->playlock);
+	//ast_mutex_unlock(&conf->playlock);
 
 	conf_flush(fd, chan);
 
@@ -2414,7 +2419,9 @@
 		conf_play(chan, conf, LEAVE);
 
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) {
-		struct announce_listitem *item = ast_calloc(1, sizeof(*item));
+		struct announce_listitem *item;
+		if (!(item = ast_calloc(1, sizeof(*item))))
+			return -1;
 		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
 		ast_copy_string(item->language, chan->language, sizeof(item->language));
 		ast_copy_string(item->channame, chan->name, sizeof(item->channame));
@@ -2427,6 +2434,7 @@
 		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_log(LOG_DEBUG, "jpeeler: deleting %s\n", user->namerecloc);
 		ast_filedelete(user->namerecloc, NULL);
 	}
 




More information about the asterisk-commits mailing list