[Asterisk-cvs] asterisk/channels chan_sip.c,1.498,1.499
markster at lists.digium.com
markster at lists.digium.com
Sat Sep 11 09:48:32 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv20603/channels
Modified Files:
chan_sip.c
Log Message:
Improve initial poking behavior (bug #2419)
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.498
retrieving revision 1.499
diff -u -d -r1.498 -r1.499
--- chan_sip.c 10 Sep 2004 02:03:05 -0000 1.498
+++ chan_sip.c 11 Sep 2004 13:50:26 -0000 1.499
@@ -4270,6 +4270,14 @@
static int sip_poke_peer(struct sip_peer *peer);
+static int sip_poke_peer_s(void *data)
+{
+ struct sip_peer *peer = data;
+ peer->pokeexpire = -1;
+ sip_poke_peer(peer);
+ return 0;
+}
+
/*--- reg_source_db: Save registration in Asterisk DB ---*/
static void reg_source_db(struct sip_peer *p)
{
@@ -4308,7 +4316,13 @@
p->addr.sin_family = AF_INET;
p->addr.sin_addr = in;
p->addr.sin_port = htons(atoi(c));
- sip_poke_peer(p);
+ if (sipsock < 0) {
+ /* SIP isn't up yet, so schedule a poke only, pretty soon */
+ if (p->pokeexpire > -1)
+ ast_sched_del(sched, p->pokeexpire);
+ p->pokeexpire = ast_sched_add(sched, rand() % 5000 + 1, sip_poke_peer_s, p);
+ } else
+ sip_poke_peer(p);
if (p->expire > -1)
ast_sched_del(sched, p->expire);
p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, (void *)p);
@@ -6445,14 +6459,6 @@
static struct ast_cli_entry cli_no_debug =
{ { "sip", "no", "debug", NULL }, sip_no_debug, "Disable SIP debugging", no_debug_usage };
-static int sip_poke_peer_s(void *data)
-{
- struct sip_peer *peer = data;
- peer->pokeexpire = -1;
- sip_poke_peer(peer);
- return 0;
-}
-
/*--- parse_moved_contact: Parse 302 Moved temporalily response */
static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
{
@@ -7818,6 +7824,8 @@
if (!peer->maxms || !peer->addr.sin_addr.s_addr) {
/* IF we have no IP, or this isn't to be monitored, return
imeediately after clearing things out */
+ if (peer->pokeexpire > -1)
+ ast_sched_del(sched, peer->pokeexpire);
peer->lastms = 0;
peer->pokeexpire = -1;
peer->call = NULL;
@@ -8368,7 +8376,7 @@
*/
v=v->next;
}
- if (!found && peer->dynamic && (sipsock > -1))
+ if (!found && peer->dynamic)
reg_source_db(peer);
peer->delme = 0;
}
More information about the svn-commits
mailing list