[Asterisk-Dev] LOCAL_USER_ADD / LOCAL_USER_REMOVE semantics ?

Luigi Rizzo rizzo at icir.org
Sat Dec 31 05:23:26 MST 2005


I am a bit unclear on the exact semantics of LOCAL_USER_ADD
and LOCAL_USER_REMOVE -- as i understand from the documentation,
they are meant to keep track of the channels using a given
module, both to signal them upon certain events, and to know
when we can unload a module because the usecount is 0.

However, for the latter we have a bit of a race,
because both macros are called within the module itself,
so localusecount can become 0 while a thread is still
executing the final part of the handler ?

I suppose a better option would be to put the
LOCAL_USER_ADD and LOCAL_USER_REMOVE calls around
the call to the module's handler in pbx_exec(),
ast_func_read() and ast_func_write() (if i haven't
missed other places).

Of course this would require to put the localuser
stuff into the module/function descriptor, but in addition
to giving correct behaviour,
this change would also give a huge simplification
in the module's code because there would be no need to
replicate the LOCALUSER calls all over the place.

Finally, the change can be made incrementally, by first
adding the localuser things (maybe with a different name)
in the wrapper, then redefining the LOCALUSER macros to empty,
and then removing them from the code as we sweep through it.

Makes sense ?

	cheers
	luigi



More information about the asterisk-dev mailing list