Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.510.2.58 diff -u -r1.510.2.58 chan_sip.c --- channels/chan_sip.c 5 Apr 2005 10:08:53 -0000 1.510.2.58 +++ channels/chan_sip.c 6 Apr 2005 02:00:23 -0000 @@ -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(®l.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(®l.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(®l.lock); - for (reg = regl.registrations; reg; reg = reg->next) - __sip_do_register(reg); - ast_mutex_unlock(®l.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(®l.lock); - for (reg = regl.registrations; reg; reg = reg->next) - __sip_do_register(reg); - ast_mutex_unlock(®l.lock); - + sip_send_all_registers(); + /* And start the monitor for the first time */ restart_monitor(); }