[Home]

Summary:ASTERISK-12288: [patch] allow pbx_lua to be used without pbx_config loaded
Reporter:Matthew Nicholson (mnicholson)Labels:
Date Opened:2008-06-30 15:04:26Date Closed:2008-09-25 16:21:06
Priority:MajorRegression?No
Status:Closed/CompleteComponents:PBX/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pbx_lua5.diff
( 1) pbx_lua6.diff
Description:This patch allows pbx_lua to be used without pbx_config being loaded by directly creating the required dialplan switches in the pbx_lua.so module.

****** ADDITIONAL INFORMATION ******

I was uncertain about the proper way to unregister the dialplan switches when the module was unloaded (examples from pbx_ael and pbx_config did not work properly), so please verify my method.

Also in the lua_register_switches() function, I believe there is a potential issue with the 'local_table' hashtab.  It will be reused if there is an error in the function.  I don't know if that will cause any problems or not.  In pbx_config and pbx_ael the table is never cleaned up so they have the same potential issue.

This patch is affected by bug 12960 when sharing contexts with pbx_ael and pbx_config.  When that issue is resolved, there will be no need for the build-extensions-conf.lua script in the utils/ directory.
Comments:By: Matthew Nicholson (mnicholson) 2008-06-30 15:17:21

I didn't update the CHANGES file, but current pbx_lua users (not sure if there are any), may need to make changes to their extensions.conf once this patch is merged.

By: Matthew Nicholson (mnicholson) 2008-07-16 10:58:47

I just uploaded pbx_lua6.diff which is a patch against r131207 (should probably work with 126574 too).  This one uses ast_context_destroy() to clean up during unload instead of ast_merge_contexts_and_delete().  This seems to work since murf's latest fixes went in.

There is still the question of clean up/reuse of the 'local_table' hash table in lua_register_switches().  See the Additional Information section of the bug description for more information.

By: Steve Murphy (murf) 2008-09-16 16:00:02

Russell asked me assign this one to myself. So I have. Will get to it soon.

By: Steve Murphy (murf) 2008-09-25 15:48:55

Not to worry; I looked at your code and it seems to be OK. I tested it against
a case where extensions.lua adds an extension to a context that already exists,
via extensions.ael. The switch is added to the existing context, which is what I'd expect.

The local_table and local_extens are gone the moment you return from merge_contexts_and_delete. The procedure goes this way:

a. read in your input file, have a local hashtab, and a local extensions list;
b. create all the contexts/extens/prios via the add_exten, etc. func calls,
  which add these items to the local list and table.
c. call merge_contexts_and_delete(), which will:
   1. traverse the existing dialplan, and copy all the stuff that
      has a different registrar into your local_hashtab and local_extens
      list.
   2. lock the local dialplan, save the hashtab and list pointers, then
      set the global dialplan hashtab and exten list pointers to be your
      local table and exten list. It will then release the lock. Takes
      around 4 micoroseconds on 3GHz machines.
   3. it then destroys what used to be the global hashtab and exten tree.
d. then you set the local hashtab and exten tree pointers to NULL. They no
  longer belong to you.

and the ast_context_destroy(NULL, "registrar") is a good way to unload;
it will remove anything that your module registrar'd into the table.

I've dropped some detail, but this is roughly how it works.

By: Steve Murphy (murf) 2008-09-25 16:21:05

OOps. forgot to put the (closes ASTERISK-12288) in the commit msg.

This code was merged into trunk via r. 144523
                    into 1.6.0 via r. 144524
                    into 1.6.1 via r. 144529