[Asterisk-cvs] asterisk/apps app_meetme.c,1.60.2.3,1.60.2.4

russell at lists.digium.com russell at lists.digium.com
Mon Jul 11 18:34:32 CDT 2005


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv11771/apps

Modified Files:
      Tag: v1-0
	app_meetme.c 
Log Message:
if the first user hangs up while being prompted for a pin, don't hold the
conference open (bug #4656)


Index: app_meetme.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v
retrieving revision 1.60.2.3
retrieving revision 1.60.2.4
diff -u -d -r1.60.2.3 -r1.60.2.4
--- app_meetme.c	15 Apr 2005 07:15:39 -0000	1.60.2.3
+++ app_meetme.c	11 Jul 2005 22:42:45 -0000	1.60.2.4
@@ -482,9 +482,39 @@
 	return res;
 }
 
+/* Remove the conference from the list and free it.
+   We assume that this was called while holding conflock. */
+static int conf_free(struct ast_conference *conf)
+{
+	struct ast_conference *prev = NULL, *cur = confs;
+
+	while(cur) {
+		if (cur == conf) {
+			if (prev)
+				prev->next = conf->next;
+			else
+				confs = conf->next;
+			break;
+		}
+		prev = cur;
+		cur = cur->next;
+	}
+
+	if (!cur)
+		ast_log(LOG_WARNING, "Conference not found\n");
+
+	if (conf->chan)
+		ast_hangup(conf->chan);
+	else
+		close(conf->fd);
+	
+	free(conf);
+
+	return 0;
+}
+
 static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags)
 {
-	struct ast_conference *prev=NULL, *cur;
 	struct ast_conf_user *user = malloc(sizeof(struct ast_conf_user));
 	int fd;
 	struct zt_confinfo ztc;
@@ -991,31 +1021,12 @@
 			"Meetme: %s\r\n"
 			"Usernum: %i\r\n",
 			chan->name, chan->uniqueid, conf->confno, user->user_no);
-		prev = NULL;
 		conf->users--;
 		if (confflags & CONFFLAG_MARKEDUSER) 
 			conf->markedusers--;
-		cur = confs;
 		if (!conf->users) {
 			/* No more users -- close this one out */
-			while(cur) {
-				if (cur == conf) {
-					if (prev)
-						prev->next = conf->next;
-					else
-						confs = conf->next;
-					break;
-				}
-				prev = cur;
-				cur = cur->next;
-			}
-			if (!cur) 
-				ast_log(LOG_WARNING, "Conference not found\n");
-			if (conf->chan)
-				ast_hangup(conf->chan);
-			else
-				close(conf->fd);
-			free(conf);
+			conf_free(conf);	
 		} else {
 			/* Remove the user struct */ 
 			if (user == conf->firstuser) {
@@ -1400,8 +1411,15 @@
 									confno[0] = '\0';
 							}
 						} else {
+							/* failed when getting the pin */
 							res = -1;
 							allowretry = 0;
+							/* see if we need to get rid of the conference */
+							ast_mutex_lock(&conflock);
+							if (!cnf->users) {
+								conf_free(cnf);	
+							}
+							ast_mutex_unlock(&conflock);
 							break;
 						}
 
@@ -1420,8 +1438,9 @@
 			}
 		}
 	} while (allowretry);
-	/* Do the conference */
+	
 	LOCAL_USER_REMOVE(u);
+	
 	return res;
 }
 




More information about the svn-commits mailing list