[asterisk-dev] Dynamically removing a provider registration entry

Johansson Olle E olle at voop.com
Thu Oct 26 22:58:30 MST 2006


27 okt 2006 kl. 06.52 skrev Craig Edwards:

> 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.
>

I would think this has to be a manager command and a cli command. You  
propably want to send an
unregister request to the service before you disable the entry. I  
would say that we should not remove
it from memory - that's a re-configuration issue, but just tell it to  
disable itself - unregister and stay
disabled until further notice.

There's propably something else holding a reference pointer to the  
object, thus sip_registry_destroy does not
get called.

/O

---
Olle E. Johansson * Asterisk Evangelist, developer * VOOP A/S
olle at voop.com





More information about the asterisk-dev mailing list