[asterisk-commits] russell: branch russell/chan_refcount r104839 - in /team/russell/chan_refcoun...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 27 15:46:13 CST 2008


Author: russell
Date: Wed Feb 27 15:46:12 2008
New Revision: 104839

URL: http://svn.digium.com/view/asterisk?view=rev&rev=104839
Log:
resolve, reset

Modified:
    team/russell/chan_refcount/   (props changed)
    team/russell/chan_refcount/apps/app_chanspy.c
    team/russell/chan_refcount/apps/app_voicemail.c
    team/russell/chan_refcount/main/file.c
    team/russell/chan_refcount/main/manager.c

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Feb 27 15:46:12 2008
@@ -1,1 +1,1 @@
-/trunk:1-104106,104108-104659
+/trunk:1-104106,104108-104838

Modified: team/russell/chan_refcount/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_chanspy.c?view=diff&rev=104839&r1=104838&r2=104839
==============================================================================
--- team/russell/chan_refcount/apps/app_chanspy.c (original)
+++ team/russell/chan_refcount/apps/app_chanspy.c Wed Feb 27 15:46:12 2008
@@ -491,9 +491,6 @@
 			if (ast_check_hangup(chan))
 				break;
 
-			if (peer == chan) {
-				continue;
-
 			if (ast_test_flag(flags, OPTION_BRIDGED) && !ast_bridged_channel(peer))
 				continue;
 
@@ -575,6 +572,7 @@
 			num_spyed_upon++;
 
 			if (res == -1) {
+				chanspy_ds_free(peer_chanspy_ds);
 				goto exit;
 			} else if (res == -2) {
 				res = 0;

Modified: team/russell/chan_refcount/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_voicemail.c?view=diff&rev=104839&r1=104838&r2=104839
==============================================================================
--- team/russell/chan_refcount/apps/app_voicemail.c (original)
+++ team/russell/chan_refcount/apps/app_voicemail.c Wed Feb 27 15:46:12 2008
@@ -8174,8 +8174,6 @@
 	char *cat;
 	struct ast_variable *var;
 	const char *val;
-	const char *s;
-	const char *key;
 	char *q, *stringp;
 	int x;
 	int tmpadsi[4];
@@ -8387,7 +8385,7 @@
 		}
 
 		/* SMDI voicemail notification */
-		if ((s = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(s)) {
+		if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
 			ast_debug(1, "Enabled SMDI voicemail notification\n");
 			if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
 				smdi_iface = ast_smdi_interface_find(val);
@@ -8410,19 +8408,19 @@
 		ast_copy_string(serveremail, val, sizeof(serveremail));
 		
 		vmmaxsecs = 0;
-		if ((s = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
-			if (sscanf(s, "%d", &x) == 1) {
+		if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
+			if (sscanf(val, "%d", &x) == 1) {
 				vmmaxsecs = x;
 			} else {
 				ast_log(LOG_WARNING, "Invalid max message time length\n");
 			}
-		} else if ((s = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
+		} else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
 			static int maxmessage_deprecate = 0;
 			if (maxmessage_deprecate == 0) {
 				maxmessage_deprecate = 1;
 				ast_log(LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
 			}
-			if (sscanf(s, "%d", &x) == 1) {
+			if (sscanf(val, "%d", &x) == 1) {
 				vmmaxsecs = x;
 			} else {
 				ast_log(LOG_WARNING, "Invalid max message time length\n");
@@ -8430,21 +8428,21 @@
 		}
 
 		vmminsecs = 0;
-		if ((s = ast_variable_retrieve(cfg, "general", "minsecs"))) {
-			if (sscanf(s, "%d", &x) == 1) {
+		if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
+			if (sscanf(val, "%d", &x) == 1) {
 				vmminsecs = x;
 				if (maxsilence <= vmminsecs)
 					ast_log(LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
 			} else {
 				ast_log(LOG_WARNING, "Invalid min message time length\n");
 			}
-		} else if ((s = ast_variable_retrieve(cfg, "general", "minmessage"))) {
+		} else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
 			static int maxmessage_deprecate = 0;
 			if (maxmessage_deprecate == 0) {
 				maxmessage_deprecate = 1;
 				ast_log(LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
 			}
-			if (sscanf(s, "%d", &x) == 1) {
+			if (sscanf(val, "%d", &x) == 1) {
 				vmminsecs = x;
 				if (maxsilence <= vmminsecs)
 					ast_log(LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
@@ -8459,16 +8457,16 @@
 		ast_copy_string(vmfmts, val, sizeof(vmfmts));
 
 		skipms = 3000;
-		if ((s = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
-			if (sscanf(s, "%d", &x) == 1) {
+		if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
+			if (sscanf(val, "%d", &x) == 1) {
 				maxgreet = x;
 			} else {
 				ast_log(LOG_WARNING, "Invalid max message greeting length\n");
 			}
 		}
 
-		if ((s = ast_variable_retrieve(cfg, "general", "skipms"))) {
-			if (sscanf(s, "%d", &x) == 1) {
+		if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
+			if (sscanf(val, "%d", &x) == 1) {
 				skipms = x;
 			} else {
 				ast_log(LOG_WARNING, "Invalid skipms value\n");
@@ -8476,8 +8474,8 @@
 		}
 
 		maxlogins = 3;
-		if ((s = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
-			if (sscanf(s, "%d", &x) == 1) {
+		if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
+			if (sscanf(val, "%d", &x) == 1) {
 				maxlogins = x;
 			} else {
 				ast_log(LOG_WARNING, "Invalid max failed login attempts\n");
@@ -8494,9 +8492,9 @@
 			val = "no";
 		ast_set2_flag((&globalflags), ast_true(val), VM_FORCEGREET);
 
-		if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
-			ast_debug(1, "VM_CID Internal context string: %s\n", s);
-			stringp = ast_strdupa(s);
+		if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
+			ast_debug(1, "VM_CID Internal context string: %s\n", val);
+			stringp = ast_strdupa(val);
 			for (x = 0; x < MAX_NUM_CID_CONTEXTS; x++) {
 				if (!ast_strlen_zero(stringp)) {
 					q = strsep(&stringp, ",");
@@ -8608,16 +8606,16 @@
 		if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
 			ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch));
 		/* load configurable audio prompts */
-		if ((key = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(key))
-			ast_copy_string(listen_control_forward_key, key, sizeof(listen_control_forward_key));
-		if ((key = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(key))
-			ast_copy_string(listen_control_reverse_key, key, sizeof(listen_control_reverse_key));
-		if ((key = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(key))
-			ast_copy_string(listen_control_pause_key, key, sizeof(listen_control_pause_key));
-		if ((key = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(key))
-			ast_copy_string(listen_control_restart_key, key, sizeof(listen_control_restart_key));
-		if ((key = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(key))
-			ast_copy_string(listen_control_stop_key, key, sizeof(listen_control_stop_key));
+		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
+			ast_copy_string(listen_control_forward_key, val, sizeof(listen_control_forward_key));
+		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
+			ast_copy_string(listen_control_reverse_key, val, sizeof(listen_control_reverse_key));
+		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
+			ast_copy_string(listen_control_pause_key, val, sizeof(listen_control_pause_key));
+		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
+			ast_copy_string(listen_control_restart_key, val, sizeof(listen_control_restart_key));
+		if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
+			ast_copy_string(listen_control_stop_key, val, sizeof(listen_control_stop_key));
 
 		if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory"))) 
 			val = "no";
@@ -8707,39 +8705,39 @@
 			ast_free(pagersubject);
 			pagersubject = NULL;
 		}
-		if ((s = ast_variable_retrieve(cfg, "general", "pbxskip")))
-			ast_set2_flag((&globalflags), ast_true(s), VM_PBXSKIP);
-		if ((s = ast_variable_retrieve(cfg, "general", "fromstring")))
-			ast_copy_string(fromstring, s, sizeof(fromstring));
-		if ((s = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
-			ast_copy_string(pagerfromstring, s, sizeof(pagerfromstring));
-		if ((s = ast_variable_retrieve(cfg, "general", "charset")))
-			ast_copy_string(charset, s, sizeof(charset));
-		if ((s = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
-			sscanf(s, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
+		if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
+			ast_set2_flag((&globalflags), ast_true(val), VM_PBXSKIP);
+		if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
+			ast_copy_string(fromstring, val, sizeof(fromstring));
+		if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
+			ast_copy_string(pagerfromstring, val, sizeof(pagerfromstring));
+		if ((val = ast_variable_retrieve(cfg, "general", "charset")))
+			ast_copy_string(charset, val, sizeof(charset));
+		if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
+			sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
 			for (x = 0; x < 4; x++) {
 				memcpy(&adsifdn[x], &tmpadsi[x], 1);
 			}
 		}
-		if ((s = ast_variable_retrieve(cfg, "general", "adsisec"))) {
-			sscanf(s, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
+		if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
+			sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
 			for (x = 0; x < 4; x++) {
 				memcpy(&adsisec[x], &tmpadsi[x], 1);
 			}
 		}
-		if ((s = ast_variable_retrieve(cfg, "general", "adsiver")))
-			if (atoi(s)) {
-				adsiver = atoi(s);
-			}
-		if ((s = ast_variable_retrieve(cfg, "general", "emailtitle"))) {
+		if ((val = ast_variable_retrieve(cfg, "general", "adsiver")))
+			if (atoi(val)) {
+				adsiver = atoi(val);
+			}
+		if ((val = ast_variable_retrieve(cfg, "general", "emailtitle"))) {
 			ast_log(LOG_NOTICE, "Keyword 'emailtitle' is DEPRECATED, please use 'emailsubject' instead.\n");
-			ast_copy_string(emailtitle, s, sizeof(emailtitle));
-		}
-		if ((s = ast_variable_retrieve(cfg, "general", "emailsubject")))
-			emailsubject = ast_strdup(s);
-		if ((s = ast_variable_retrieve(cfg, "general", "emailbody"))) {
+			ast_copy_string(emailtitle, val, sizeof(emailtitle));
+		}
+		if ((val = ast_variable_retrieve(cfg, "general", "emailsubject")))
+			emailsubject = ast_strdup(val);
+		if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
 			char *tmpread, *tmpwrite;
-			emailbody = ast_strdup(s);
+			emailbody = ast_strdup(val);
 
 			/* substitute strings \t and \n into the appropriate characters */
 			tmpread = tmpwrite = emailbody;
@@ -8763,11 +8761,11 @@
 				tmpread = tmpwrite + 1;
 			}
 		}
-		if ((s = ast_variable_retrieve(cfg, "general", "pagersubject")))
-			pagersubject = ast_strdup(s);
-		if ((s = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
+		if ((val = ast_variable_retrieve(cfg, "general", "pagersubject")))
+			pagersubject = ast_strdup(val);
+		if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
 			char *tmpread, *tmpwrite;
-			pagerbody = ast_strdup(s);
+			pagerbody = ast_strdup(val);
 
 			/* substitute strings \t and \n into the appropriate characters */
 			tmpread = tmpwrite = pagerbody;

Modified: team/russell/chan_refcount/main/file.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/file.c?view=diff&rev=104839&r1=104838&r2=104839
==============================================================================
--- team/russell/chan_refcount/main/file.c (original)
+++ team/russell/chan_refcount/main/file.c Wed Feb 27 15:46:12 2008
@@ -546,7 +546,7 @@
 	}
 	if (preflang == NULL)
 		preflang = "";
-	buflen = strlen(preflang) + strlen(filename) + 2;
+	buflen = strlen(preflang) + strlen(filename) + 4;
 	buf = alloca(buflen);
 	if (buf == NULL)
 		return NULL;
@@ -577,7 +577,7 @@
 
 	if (preflang == NULL)
 		preflang = "";
-	buflen = strlen(preflang) + strlen(filename) + 2;
+	buflen = strlen(preflang) + strlen(filename) + 4;
 	buf = alloca(buflen);
 	if (buf == NULL)
 		return NULL;
@@ -804,7 +804,7 @@
 
 	if (preflang == NULL)
 		preflang = "";
-	buflen = strlen(preflang) + strlen(filename) + 2;	/* room for everything */
+	buflen = strlen(preflang) + strlen(filename) + 4;	/* room for everything */
 	buf = alloca(buflen);
 	if (buf == NULL)
 		return 0;

Modified: team/russell/chan_refcount/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/manager.c?view=diff&rev=104839&r1=104838&r2=104839
==============================================================================
--- team/russell/chan_refcount/main/manager.c (original)
+++ team/russell/chan_refcount/main/manager.c Wed Feb 27 15:46:12 2008
@@ -3488,7 +3488,12 @@
 		ast_mutex_init(&s->__lock);
 		ast_mutex_lock(&s->__lock);
 		s->inuse = 1;
-		s->managerid = (rand() ^ (unsigned long) s) | 1;	/* make sure it is non-zero */
+		/*!\note There is approximately a 1 in 1.8E19 chance that the following
+		 * calculation will produce 0, which is an invalid ID, but due to the
+		 * properties of the rand() function (and the constantcy of s), that
+		 * won't happen twice in a row.
+		 */
+		while ((s->managerid = rand() ^ (unsigned long) s) == 0);
 		s->last_ev = grab_last();
 		AST_LIST_LOCK(&sessions);
 		AST_LIST_INSERT_HEAD(&sessions, s, list);




More information about the asterisk-commits mailing list