[asterisk-commits] tilghman: branch tilghman/compiler_attributes r133807 - in /team/tilghman/com...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 25 14:53:00 CDT 2008


Author: tilghman
Date: Fri Jul 25 14:52:59 2008
New Revision: 133807

URL: http://svn.digium.com/view/asterisk?view=rev&rev=133807
Log:
Merged revisions 133651,133665,133710,133770 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r133651 | bkruse | 2008-07-25 12:21:46 -0500 (Fri, 25 Jul 2008) | 5 lines

Committing a fix that was introduced a long time
ago (does not affect 1.4), where you would pass
a pointer to the end of a character array, and
ast_uri_decode would do no good.

................
r133665 | tilghman | 2008-07-25 12:24:43 -0500 (Fri, 25 Jul 2008) | 16 lines

Merged revisions 133649 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r133649 | tilghman | 2008-07-25 12:19:39 -0500 (Fri, 25 Jul 2008) | 8 lines

Fix some errant device states by making the devicestate API more strict in
terms of the device argument (only without the unique identifier appended).
(closes issue #12771)
 Reported by: davidw
 Patches: 
       20080717__bug12771.diff.txt uploaded by Corydon76 (license 14)
 Tested by: davidw, jvandal, murf

........

................
r133710 | tilghman | 2008-07-25 13:01:58 -0500 (Fri, 25 Jul 2008) | 10 lines

Blocked revisions 133709 via svnmerge

........
r133709 | tilghman | 2008-07-25 13:00:33 -0500 (Fri, 25 Jul 2008) | 3 lines

Remove unnecessary mmap flag
(Closes issue #13161)

........

................
r133770 | bkruse | 2008-07-25 14:12:17 -0500 (Fri, 25 Jul 2008) | 7 lines

Revert tilghman and pari's code changes, as
we do NOT need to uri_decode in manager.
(if I sent core%20show%20channels from a telnet
session, it should be interpreted literally, however,
if I send that from an http session, it should be
decoded, which is the behaivor now)

................

Modified:
    team/tilghman/compiler_attributes/   (props changed)
    team/tilghman/compiler_attributes/channels/chan_agent.c
    team/tilghman/compiler_attributes/main/channel.c
    team/tilghman/compiler_attributes/main/devicestate.c
    team/tilghman/compiler_attributes/main/http.c
    team/tilghman/compiler_attributes/main/manager.c

Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jul 25 14:52:59 2008
@@ -1,1 +1,1 @@
-/trunk:1-133636
+/trunk:1-133806

Modified: team/tilghman/compiler_attributes/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_agent.c?view=diff&rev=133807&r1=133806&r2=133807
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_agent.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_agent.c Fri Jul 25 14:52:59 2008
@@ -272,6 +272,18 @@
 	const char *device;
 	enum ast_device_state state;
 
+	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
+
+	if (ast_strlen_zero(device)) {
+		return;
+	}
+
+	/* Skip Agent status */
+	if (!strncasecmp(device, "Agent/", 6)) {
+		return;
+	}
+
 	/* Try to be safe, but don't deadlock */
 	for (i = 0; i < 10; i++) {
 		if ((res = AST_LIST_TRYLOCK(&agents)) == 0) {
@@ -279,14 +291,6 @@
 		}
 	}
 	if (res) {
-		return;
-	}
-
-	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
-	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
-
-	if (ast_strlen_zero(device)) {
-		AST_LIST_UNLOCK(&agents);
 		return;
 	}
 
@@ -514,6 +518,7 @@
 			}
 			p->chan = NULL;
 			p->inherited_devicestate = -1;
+			ast_device_state_changed("Agent/%s", p->agent);
 			p->acknowledged = 0;
 		}
  	} else {
@@ -729,6 +734,7 @@
 		/* Agent hung-up */
 		p->chan = NULL;
 		p->inherited_devicestate = -1;
+		ast_device_state_changed("Agent/%s", p->agent);
 	}
 
 	if (!res) {
@@ -850,6 +856,7 @@
 				ast_hangup(p->chan);
 				p->chan = NULL;
 				p->inherited_devicestate = -1;
+				ast_device_state_changed("Agent/%s", p->agent);
 			}
 			ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
 			if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {

Modified: team/tilghman/compiler_attributes/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/channel.c?view=diff&rev=133807&r1=133806&r2=133807
==============================================================================
--- team/tilghman/compiler_attributes/main/channel.c (original)
+++ team/tilghman/compiler_attributes/main/channel.c Fri Jul 25 14:52:59 2008
@@ -1277,7 +1277,7 @@
 	struct ast_frame *f;
 	struct varshead *headp;
 	struct ast_datastore *datastore = NULL;
-	char name[AST_CHANNEL_NAME];
+	char name[AST_CHANNEL_NAME], *dashptr;
 	
 	headp=&chan->varshead;
 	
@@ -1310,6 +1310,9 @@
 		sched_context_destroy(chan->sched);
 
 	ast_copy_string(name, chan->name, sizeof(name));
+	if ((dashptr = strrchr(name, '-'))) {
+		*dashptr = '\0';
+	}
 
 	/* Stop monitoring */
 	if (chan->monitor)
@@ -4086,12 +4089,18 @@
 int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
 {
 	int oldstate = chan->_state;
+	char name[AST_CHANNEL_NAME], *dashptr;
 
 	if (oldstate == state)
 		return 0;
 
+	ast_copy_string(name, chan->name, sizeof(name));
+	if ((dashptr = strrchr(name, '-'))) {
+		*dashptr = '\0';
+	}
+
 	chan->_state = state;
-	ast_devstate_changed(state == AST_STATE_DOWN ? AST_DEVICE_NOT_INUSE : AST_DEVICE_INUSE, "%s", chan->name);
+	ast_devstate_changed(state == AST_STATE_DOWN ? AST_DEVICE_NOT_INUSE : AST_DEVICE_INUSE, "%s", name);
 	/* setstate used to conditionally report Newchannel; this is no more */
 	manager_event(EVENT_FLAG_CALL,
 		      "Newstate",

Modified: team/tilghman/compiler_attributes/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/devicestate.c?view=diff&rev=133807&r1=133806&r2=133807
==============================================================================
--- team/tilghman/compiler_attributes/main/devicestate.c (original)
+++ team/tilghman/compiler_attributes/main/devicestate.c Fri Jul 25 14:52:59 2008
@@ -457,15 +457,11 @@
 	devstate_event(device, state, CACHE_OFF);
 }
 
-static int __ast_devstate_changed_literal(enum ast_device_state state, char *buf, int norecurse)
-{
-	char *device;
+int ast_devstate_changed_literal(enum ast_device_state state, const char *device)
+{
 	struct state_change *change;
-	char *tmp = NULL;
-
-	ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf);
-
-	device = buf;
+
+	ast_debug(3, "Notification of state change to be queued on device/channel %s\n", device);
 
 	if (state != AST_DEVICE_UNKNOWN) {
 		devstate_event(device, state, CACHE_ON);
@@ -482,37 +478,12 @@
 		AST_LIST_UNLOCK(&state_changes);
 	}
 
-	/* The problem with this API is that a device may be called with the unique
-	 * identifier appended or not, but it's separated from the channel name
-	 * with a '-', which is also a legitimate character in a channel name.  So,
-	 * we have to force both names to get their names checked for state changes
-	 * to ensure that the right one gets notified.  Not a huge performance hit,
-	 * but it might could be fixed by an enterprising programmer in trunk.
-	 */
-	if (!norecurse && (tmp = strrchr(device, '-'))) {
-		*tmp = '\0';
-		__ast_devstate_changed_literal(state, device, 1);
-	}
-	
 	return 1;
 }
 
-int ast_devstate_changed_literal(enum ast_device_state state, const char *dev)
-{
-	char *buf;
-
-	buf = ast_strdupa(dev);
-
-	return __ast_devstate_changed_literal(state, buf, 0);
-}
-
 int ast_device_state_changed_literal(const char *dev)
 {
-	char *buf;
-
-	buf = ast_strdupa(dev);
-
-	return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0);
+	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev);
 }
 
 int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...) 
@@ -524,7 +495,7 @@
 	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
-	return __ast_devstate_changed_literal(state, buf, 0);
+	return ast_devstate_changed_literal(state, buf);
 }
 
 /*! \brief Accept change notification, add it to change queue */
@@ -537,7 +508,7 @@
 	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
-	return __ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf, 0);
+	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf);
 }
 
 /*! \brief Go through the dev state change queue and update changes in the dev state thread */

Modified: team/tilghman/compiler_attributes/main/http.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/http.c?view=diff&rev=133807&r1=133806&r2=133807
==============================================================================
--- team/tilghman/compiler_attributes/main/http.c (original)
+++ team/tilghman/compiler_attributes/main/http.c Fri Jul 25 14:52:59 2008
@@ -400,10 +400,13 @@
  */
 static void http_decode(char *s)
 {
-	for (;*s; s++) {
-		if (*s == '+')
-			*s = ' ';
-	}
+	char *t;
+	
+	for (t = s; *t; t++) {
+		if (*t == '+')
+			*t = ' ';
+	}
+
 	ast_uri_decode(s);
 }
 

Modified: team/tilghman/compiler_attributes/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/manager.c?view=diff&rev=133807&r1=133806&r2=133807
==============================================================================
--- team/tilghman/compiler_attributes/main/manager.c (original)
+++ team/tilghman/compiler_attributes/main/manager.c Fri Jul 25 14:52:59 2008
@@ -1270,8 +1270,7 @@
 {
 	int x;
 	char hdr[40];
-	const char *action, *cat, *match, *line, *tmp;
-	char *var, *value;
+	const char *action, *cat, *var, *value, *match, *line;
 	struct ast_category *category;
 	struct ast_variable *v;
 	struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16);
@@ -1287,23 +1286,10 @@
 		snprintf(hdr, sizeof(hdr), "Cat-%06d", x);
 		cat = astman_get_header(m, hdr);
 		snprintf(hdr, sizeof(hdr), "Var-%06d", x);
-		if ((tmp = astman_get_header(m, hdr))) {
-			ast_str_make_space(&str1, strlen(tmp) + 1);
-			strcpy(str1->str, tmp);
-			var = str1->str;
-			ast_uri_decode(var);
-		} else {
-			var = "";
-		}
+		var = astman_get_header(m, hdr);
 		snprintf(hdr, sizeof(hdr), "Value-%06d", x);
-		if ((tmp = astman_get_header(m, hdr))) {
-			ast_str_make_space(&str2, strlen(tmp) + 1);
-			strcpy(str2->str, tmp);
-			value = str2->str;
-			ast_uri_decode(value);
-		} else {
-			value = "";
-		}
+		value = astman_get_header(m, hdr);
+
 		if (!ast_strlen_zero(value) && *value == '>') {
 			object = 1;
 			value++;




More information about the asterisk-commits mailing list