[asterisk-commits] mjordan: branch 1.8 r370666 - /branches/1.8/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 31 15:54:40 CDT 2012
Author: mjordan
Date: Tue Jul 31 15:54:34 2012
New Revision: 370666
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370666
Log:
Schedule pokes of registered SIP peers within a given timespan after SIP reload
With a large number of SIP peers registered, performing a SIP reload causes a
flood of SIP OPTIONS request packets. These are immediately sent out, and, as
responses come back, can cause peers to be flagged as 'lagged' due to handling
of the many response messages.
This fix prevents this "packet storm" and schedules the pokes for a random
time. That time varies between 1 ms and the peer's qualify time, or, if
the qualify time is unknown, the global qualifyfreq setting.
The committed patch has some very small modifications to the patch schmidts
wrote for the review.
(closes issue ASTERISK-19154)
Reported by: Nicolo Mazzon
patches:
issue19154.patch license #6034 uploaded by schmidts
Review: https://reviewboard.asterisk.org/r/1652
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=370666&r1=370665&r2=370666
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Jul 31 15:54:34 2012
@@ -13942,14 +13942,14 @@
peer->name, peer->username, ast_sockaddr_stringify_host(&sa), expire);
ast_sockaddr_copy(&peer->addr, &sa);
- if (sipsock < 0) {
- /* SIP isn't up yet, so schedule a poke only, pretty soon */
- AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched, ast_random() % 5000 + 1, sip_poke_peer_s, peer,
+ if (peer->maxms) {
+ /* Don't poke peer immediately, just schedule it within qualifyfreq */
+ AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched,
+ ast_random() % ((peer->qualifyfreq) ? peer->qualifyfreq : global_qualifyfreq) + 1,
+ sip_poke_peer_s, peer,
unref_peer(_data, "removing poke peer ref"),
unref_peer(peer, "removing poke peer ref"),
ref_peer(peer, "adding poke peer ref"));
- } else {
- sip_poke_peer(peer, 0);
}
AST_SCHED_REPLACE_UNREF(peer->expire, sched, (expire + 10) * 1000, expire_register, peer,
unref_peer(_data, "remove registration ref"),
@@ -29807,16 +29807,19 @@
i = ao2_iterator_init(peers, 0);
while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
ao2_lock(peer);
- if (num == global_qualify_peers) {
- ms += global_qualify_gap;
- num = 0;
- } else {
- num++;
- }
- AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched, ms, sip_poke_peer_s, peer,
- unref_peer(_data, "removing poke peer ref"),
- unref_peer(peer, "removing poke peer ref"),
- ref_peer(peer, "adding poke peer ref"));
+ /* Don't schedule poking on a peer without qualify */
+ if (peer->maxms) {
+ if (num == global_qualify_peers) {
+ ms += global_qualify_gap;
+ num = 0;
+ } else {
+ num++;
+ }
+ AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched, ms, sip_poke_peer_s, peer,
+ unref_peer(_data, "removing poke peer ref"),
+ unref_peer(peer, "removing poke peer ref"),
+ ref_peer(peer, "adding poke peer ref"));
+ }
ao2_unlock(peer);
unref_peer(peer, "toss iterator peer ptr");
}
More information about the asterisk-commits
mailing list