[Asterisk-Dev] LOCAL_USER cleanup update

Luigi Rizzo rizzo at icir.org
Wed Jan 11 06:21:50 MST 2006


As mentioned a few times e.g. in

        http://bugs.digium.com/view.php?id=6146

i am in the process of moving the LOCAL_USER calls within the loader,
thus removing all the instances of identical code that at the moment
are repeated in each module. This is in the interest of code size,
clarity and correctness. It is also a useful complement to the
work i am doing on the improved loader as documented in

        http://bugs.digium.com/view.php?id=4377

Fixing LOCAL_USER* requires the following steps:

 1   fix abuses of the 'struct localuser' structure. These are
     in app_dial, app_externalivr, app_queue, see description
     below;

 2   #define STANDARD_LOCALUSER to empty, and fix accordingly
     the code in asterisk/module.h

 3   move the functionality of the LOCAL_USER_* macros into 
     the loader, together with the changes in

        http://bugs.digium.com/view.php?id=4377

     and #define LOCAL_USER_* to empty as they are now useless

 4   remove the (now empty) LOCAL_USER_ macros from all the
     modules involved.

I have #1 and #2 ready and running, #3 is a matter of hours.
#4 is trivial (and optional) but it requires a sweep of all
modules using the macros.

The problem is, all of these patches are conceptually trivial, _but_
#1 is a bit large because it involves a bit of renaming from 'struct
localuser' to 'struct somethingelse' in the offending modules, and
so i really need some committer to work with me on this, otherwise
i'd have to regenerate the diff a million times.  Same for #4,
which, besides, might interfere a bit with the loader changes.

So before posting actual code on mantis (i probably will
anyways, once the public svn server is working again),
I'd like to ask that interested committers contact me privately by
email to see if there is interest and schedule the work.

        thanks
        luigi


--- How 'struct localuser' is abused ---

Step #1 above would be unnecessary if 'struct localuser' were
used for their task, which is to keep track of a list of
channels using a module. Unfortunately this is not the case.

The only purpose of the macro STANDARD_LOCALUSER is to
define a 'struct localuser', which _in principle_ should be the
same for all modules. So, in principle, the macro could be
redefined to empty (or removed from all files invoking it)
and the structure simply defined once for all in module.h

Doing this showed that are a few apps (namely app_dial, app_externalivr,
app_queue) which are redefining struct localuser in a totally
unnecessary way, as follows:

  app_dial needs to store, for each invocation, a list of channels
        being dialed, and used instances of 'struct localuser' to
        store that.

  app_externalivr needs to store lists of files, and uses one
        instance of 'struct localuser' to store the pointers to
        the head of these lists.

  app_queue needs to store a list of channels with some extra information,
        and used instances of 'struct localuser' for this.

In all cases, these instances of 'struct localuser' are totally
independent from the "localusers" list handled by the LOCAL_USER_*
macros - entries are allocaded and freed explicitly.
There is absolutely no reason to redefine 'struct localuser'.

I have replaced these instances with private structures,
so that the system now compiles cleanly with STANDARD_LOCALUSER
defined to empty.
---------------------------------------------------------------




More information about the asterisk-dev mailing list