[asterisk-commits] marquis: branch 1.8 r296352 - /branches/1.8/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 26 12:19:10 CST 2010


Author: marquis
Date: Fri Nov 26 12:19:02 2010
New Revision: 296352

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=296352
Log:
Fix reloading of peer when a user is requested.

Prevent peer reloading from causing multiple MWI subscriptions to be created when using realtime.  This had the effect of sending one NOTIFY for every time a sip peer made a call, in one case eventually overwhelming  the phone and causing it to reboot.

(closes issue #18342)
Reported by: nivek
Patches:
      issue0018342p1.patch uploaded by nivek (license 636)
Tested by: nivek

Review: https://reviewboard.asterisk.org/r/1029/

Modified:
    branches/1.8/channels/chan_sip.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=296352&r1=296351&r2=296352
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri Nov 26 12:19:02 2010
@@ -1417,7 +1417,7 @@
 static void update_peer(struct sip_peer *p, int expire);
 static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config);
 static const char *get_name_from_variable(struct ast_variable *var, const char *newpeername);
-static struct sip_peer *realtime_peer(const char *peername, struct ast_sockaddr *sin, int devstate_only);
+static struct sip_peer *realtime_peer(const char *peername, struct ast_sockaddr *sin, int devstate_only, int which_objects);
 static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 
 /*--- Internal UA client handling (outbound registrations) */
@@ -4395,7 +4395,7 @@
  * This returns a pointer to a peer and because we use build_peer, we can rest
  * assured that the refcount is bumped.
 */
-static struct sip_peer *realtime_peer(const char *newpeername, struct ast_sockaddr *addr, int devstate_only)
+static struct sip_peer *realtime_peer(const char *newpeername, struct ast_sockaddr *addr, int devstate_only, int which_objects)
 {
 	struct sip_peer *peer;
 	struct ast_variable *var = NULL;
@@ -4519,11 +4519,19 @@
 	}
 
 	for (tmp = var; tmp; tmp = tmp->next) {
-		if (!newpeername && !strcasecmp(tmp->name, "name")) {
+		if (!strcasecmp(tmp->name, "type") && (!strcasecmp(tmp->value, "peer") && which_objects == FINDUSERS)) {
+			if (peerlist) {
+				ast_config_destroy(peerlist);
+			} else {
+				ast_variables_destroy(var);
+				ast_variables_destroy(varregs);
+			}
+			return NULL;
+		} else if (!newpeername && !strcasecmp(tmp->name, "name")) {
 			newpeername = tmp->value;
 		}
 	}
-	
+
 	if (!newpeername) {	/* Did not find peer in realtime */
 		ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", ipaddr);
 		if(peerlist)
@@ -4638,7 +4646,7 @@
 	}
 
 	if (!p && (realtime || devstate_only)) {
-		p = realtime_peer(peer, addr, devstate_only);
+		p = realtime_peer(peer, addr, devstate_only, which_objects);
 		if (p) {
 			switch (which_objects) {
 			case FINDUSERS:




More information about the asterisk-commits mailing list