[asterisk-dev] Reload module
Matthew Jordan
mjordan at digium.com
Thu May 24 08:21:53 CDT 2012
----- Original Message -----
> From: "Yaroslav Panych" <panych.y at gmail.com>
> To: "Asterisk Developers Mailing List" <asterisk-dev at lists.digium.com>
> Sent: Thursday, May 24, 2012 8:09:35 AM
> Subject: Re: [asterisk-dev] Reload module
>
> 2012/5/24 Matthew Jordan <mjordan at digium.com>:
> >
> > ----- Original Message -----
> >> From: "Yaroslav Panych" <panych.y at gmail.com>
> >
> > Yes - take a look at ast_module_reload. The CLI command 'module
> > reload'
> > uses this function to reload a specific Asterisk module.
>
> Yes, I know about ast_module_reload, But it hidden in
> asterisk/_private.h with warning: "normally not used by modules". So
> I
> don't know if it is safe to use it inside modules. More precisely -
> inside AMI action handler? I want to avoid all possible deadlocks.
If you knew this method existed, why did you ask if "Is there any possibility
to load/unload/reload specific module from other C module?" Clearly there
was a mechanism to reload a specific module in Asterisk. Did you expect
there to be multiple mechanisms?
Its not surprising that there would be a warning associated with this
method - it is highly suspect that an external module would want or need
to reload another external module. There are a number of pitfalls you could
run into by encouraging the use of this function in external modules:
* Circular dependencies, wherein A reloads B, and during B's reload, it
attempts to reload A
* Unanticipated reloads, wherein B does not expect to be reloaded during
a particular operation or period of time and A reloads it anyway (this
is less of a concern, given that reloads can feasibly happen at anytime
anyway)
* Poor dependency planning, wherein A expects B to exist and issues a reload
but B was never loaded
* Simultaneous reloads, wherein A issues a reload of module B and a CLI
command issues a reload of B at the same time
So yes, you really should not be doing what you're planning on doing - but
you didn't ask if we thought what you were doing was wise, merely whether
or not it was possible. And it is possible.
As far as avoiding deadlocks: that's up to your implementation. I will not
claim that you 'won't run into deadlocks' with this method. At the very
least, the method is executed in the context of a CLI handler thread, so
you can make some basic assumptions about the thread safety from that
knowledge. But its up to you to make sure you don't cause a deadlock in the
modules you reload.
>
> regards, Yaroslav
>
> --
--
Matthew Jordan
Digium, Inc. | Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
More information about the asterisk-dev
mailing list