[asterisk-dev] Dynamically removing a provider registration entry

Craig Edwards craig at haenterprises.com.au
Thu Oct 26 21:52:53 MST 2006


We have a local requirement to dynamically remove entries from the list 
of currently registered proxies.  Originally, I was just removing the 
entry from sip.conf and calling "sip reload", but we have a couple of 
thousand of proxies in our sip.conf and going through the process of 
doing DNS lookups and re-registering them all takes several minutes 
(during which time, normal asterisk call handling just stops). 

To remedy this, I have written a small patch to chan_sip.c to add a new 
function that can remove a specific entry.

if ((registry = ASTOBJ_CONTAINER_FIND_UNLINK(&regl, tmp))) {
  if (registry->call) {
    registry->call->registry = NULL;
    sip_destroy(registry->call);
 }
  ASTOBJ_UNREF(registry, sip_registry_destroy);
}

Now, this seems to work just fine for those that are in Registered state 
(it removes the entry from regl and there doesn't appear to be anything 
left in the scheduler), but for those that are in Reg Sent/Auth Sent 
(and maybe others), there are still entries in the scheduler to retry 
again in a few minutes.  The only way I have found to get them out of 
the scheduler is to add the following line just before the 
ASTOBJ_UNREF() call:

  registry->regattempts = 1000000;

If I don't do this, the sip_reg_timeout() function happily puts it back 
into the scheduler after it gets called back.  It seems to work, but it 
makes me a bit nervous...  it seems like a bit of a kludge!  Are there 
any other cases like this that I need to cater for?  Or alternatively, 
is there a better way to remove an entry at runtime without doing a 
reload?  Any advice would be much appreciated.

--
Craig


More information about the asterisk-dev mailing list