[Asterisk-cvs] asterisk/channels chan_sip.c,1.510.2.58,1.510.2.59

russell at lists.digium.com russell at lists.digium.com
Wed Apr 6 12:16:25 CDT 2005


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

Modified Files:
      Tag: v1-0
	chan_sip.c 
Log Message:
space out initial registrations (bug #3104)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.510.2.58
retrieving revision 1.510.2.59
diff -u -d -r1.510.2.58 -r1.510.2.59
--- chan_sip.c	5 Apr 2005 10:08:53 -0000	1.510.2.58
+++ chan_sip.c	6 Apr 2005 17:09:03 -0000	1.510.2.59
@@ -9131,19 +9131,31 @@
 	ast_mutex_unlock(&peerl.lock);
 }
 
+/* Send all of our registrations, spaced out to avoid suicide*/
+static void sip_send_all_registers(void)
+{
+	struct sip_registry *reg;	
+	int ms;
+	ast_mutex_lock(&regl.lock);
+	for (reg = regl.registrations; reg; reg = reg->next) { 
+		if (reg->expire > -1)
+			ast_sched_del(sched, reg->expire);
+		ms = (rand() >> 12) & 0x1fff;
+		reg->expire = ast_sched_add(sched, ms, sip_reregister, reg);
+	}
+	ast_mutex_unlock(&regl.lock);
+}
+
 /*--- sip_do_reload: Reload module */
 static int sip_do_reload(void)
 {
-	struct sip_registry *reg;
 	struct sip_peer *peer;
 	delete_users();
 	reload_config();
 	prune_peers();
-	/* And start the monitor for the first time */
-	ast_mutex_lock(&regl.lock);
-	for (reg = regl.registrations; reg; reg = reg->next) 
-		__sip_do_register(reg);
-	ast_mutex_unlock(&regl.lock);
+	
+	sip_send_all_registers();	
+	
 	ast_mutex_lock(&peerl.lock);
 	for (peer = peerl.peers; peer; peer = peer->next)
 		sip_poke_peer(peer);
@@ -9179,7 +9191,6 @@
 {
 	int res;
 	struct sip_peer *peer;
-	struct sip_registry *reg;
 
 	ast_mutex_init(&userl.lock);
 	ast_mutex_init(&peerl.lock);
@@ -9228,11 +9239,8 @@
 			sip_poke_peer(peer);
 		ast_mutex_unlock(&peerl.lock);
 
-		ast_mutex_lock(&regl.lock);
-		for (reg = regl.registrations; reg; reg = reg->next) 
-			__sip_do_register(reg);
-		ast_mutex_unlock(&regl.lock);
-		
+		sip_send_all_registers();	
+
 		/* And start the monitor for the first time */
 		restart_monitor();
 	}




More information about the svn-commits mailing list