asterisk/channels
Steve Murphy 377e51c4d4 (closes issue #6002)
Reported by: rizzo
Tested by: murf

Proposal of the changes to be made, and then an announcement of how they were accomplished:

http://lists.digium.com/pipermail/asterisk-dev/2008-February/032065.html

and:

http://lists.digium.com/pipermail/asterisk-dev/2008-March/032124.html

Here is a recap, file by file, of what I have done:

pbx/pbx_config.c
pbx/pbx_ael.c

All funcs that were passed a ptr to the context list, now will ALSO be passed a hashtab ptr to the same set.
Why? because (for the time being), the dialplan is stored in both, to facilitate a quick, low-cost move to
hash-tables to speed up dialplan processing. If it was deemed necessary to pass the context LIST, well, it
is just as necessary to have the TABLE available. This is because the list/table in question might not be
the global one, but temporary ones we would use to stage the dialplan on, and then swap into the global
position when things are ready.

We now have one external function for apps to use, "ast_context_find_or_create()" instead of the pre-existing
"find" and "create", as all existing usages used both in tandem anyway.

pbx_config, and pbx_ael, will stage the reloaded dialplan into local lists and tables, and 
then call merge_contexts_and_delete, which will merge (now) existing contexts and 
priorities from other registrars into this local set by copying them. Then, merge_contexts_and_delete will
lock down the contexts, swap the lists and tables, and unlock (real quick), and then 
destroy the old dialplan.



chan_sip.c
chan_iax.c
chan_skinny.c

All the channel drivers that would add regcontexts now use the ast_context_find_or_create now.

chan_sip also includes a small fix to get rid of warnings about removing priorities that never got entered.


apps/app_meetme.c
apps/app_dial.c
apps/app_queue.c

All the apps that added a context/exten/priority were also modified to use ast_context_find_or_create instead.


include/asterisk/pbx.h

ast_context_create() is removed. Find_or_create_ is the new method.
ast_context_find_or_create()  interface gets the hashtab added.
ast_merge_contexts_and_delete() gets the local hashtab arg added.
ast_wrlock_contexts_version() is added so you can detect if someone else got a writelock between your readlocking and writelocking.
ast_hashtab_compare_contexts was made public for use in pbx_config/pbx_ael
ast_hashtab_hash_contexts was in like fashion make public.


include/asterisk/pval.h

ast_compile_ael2() interface changed to include the local hashtab table ptr.


main/features.c

For the sake of the parking context, we use ast_context_find_or_create().



main/pbx.c

I changed all the "tree" names to "table" instead. That's because the original
implementation was based on binary trees. (had a free library). Then I moved
to hashtabs. Now, the names move forward too.

refcount field added to contexts, so you can keep track of how many modules
wanted this context to exist.

Some log messages that are warnings were inflated from LOG_NOTICE to LOG_WARNING.

Added some calls to ast_verb(3,...) for debug messages

Lots of little mods to ast_context_remove_extension2, which is now excersized in ways
it was not previously; one definite bug fixed.

find_or_create was upgraded to handle both local lists/tables as well as the globals.

context_merge() was added to do the per-context merging of the old/present contexts/extens/prios into the new/proposed local list/tables

ast_merge_contexts_and_delete() was heavily modified.

ast_add_extension2() was also upgraded to handle changes. 

the context_destroy() code was re-engineered to handle the new way of doing things,
by exten/prio instead of by context.



res/ael/pval.c
res/ael/ael.tab.c
res/ael/ael.tab.h
res/ael/ael.y
res/ael/ael_lex.c
res/ael/ael.flex
utils/ael_main.c
utils/extconf.c
utils/conf2ael.c
utils/Makefile

Had to change the interface to ast_compile_ael2(), to include the hashtab ptr.
This ended up involving several external apps.  The main gotcha was I had to 
include lock.h and hashtab.h in several places.


As a side note, I tested this stuff pretty thoroughly, I replicated the problems
originally reported by Luigi, and made triply sure that reloads worked, and everything
worked thru "stop gracefully". I found a and fixed a few bugs as I was merging into
trunk, that did not appear in my tests of bug6002.

How's this for verbose commit messages?




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@106757 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-07 18:57:57 +00:00
..
h323 Merged revisions 103823 via svnmerge from 2008-02-19 20:31:15 +00:00
misdn Fix up some doxygen issues. 2008-02-15 17:29:08 +00:00
xpmr Allow chan_usbradio to compile again. 2007-10-17 16:09:01 +00:00
DialTone.h Doxygen updates, formatting. 2007-12-11 22:20:22 +00:00
Makefile Re-inserting chan_vpb into trunk. 2008-01-28 21:07:18 +00:00
chan_agent.c Merged revisions 104086 via svnmerge from 2008-02-25 18:38:51 +00:00
chan_alsa.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_console.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_features.c remove another set of redundant #include "asterisk/options.h" 2007-11-21 23:24:55 +00:00
chan_gtalk.c Remove unnecessary if statements before calling iks_delete (redundant check is 2008-02-29 14:15:03 +00:00
chan_h323.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_iax2.c (closes issue #6002) 2008-03-07 18:57:57 +00:00
chan_jingle.c Remove unnecessary if statements before calling iks_delete (redundant check is 2008-02-29 14:15:03 +00:00
chan_local.c Merged revisions 105570 via svnmerge from 2008-03-03 17:17:27 +00:00
chan_mgcp.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_misdn.c Merged revisions 106552 via svnmerge from 2008-03-07 06:54:47 +00:00
chan_nbs.c remove another set of redundant #include "asterisk/options.h" 2007-11-21 23:24:55 +00:00
chan_oss.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_phone.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_sip.c (closes issue #6002) 2008-03-07 18:57:57 +00:00
chan_skinny.c (closes issue #6002) 2008-03-07 18:57:57 +00:00
chan_unistim.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
chan_usbradio.c Merge changes from team/mvanbaak/cli-command-audit 2008-02-08 21:26:32 +00:00
chan_vpb.cc Fix crash when configuration does not match hardware detection. 2008-02-28 14:42:32 +00:00
chan_zap.c Merged revisions 106235 via svnmerge from 2008-03-05 22:43:22 +00:00
console_board.c The fixes in this commit are mainly to allow compiling of trunk with --enable-dev-mode, mutex profiling, lock debugging, etc. Mainly, the version.c needs to be in the OBJS line; asterisk.h was chosen to have the prototypes for ast_get_version, ast_get_version_num; and the ASTERISK_FILE_VERSION macro needs to be used after including asterisk.h in a few files. I hope I did the right thing. If not, let me know. 2008-01-10 00:50:39 +00:00
console_gui.c Fix minor misuses of snprintf 2008-03-04 23:10:45 +00:00
console_video.c The fixes in this commit are mainly to allow compiling of trunk with --enable-dev-mode, mutex profiling, lock debugging, etc. Mainly, the version.c needs to be in the OBJS line; asterisk.h was chosen to have the prototypes for ast_get_version, ast_get_version_num; and the ASTERISK_FILE_VERSION macro needs to be used after including asterisk.h in a few files. I hope I did the right thing. If not, let me know. 2008-01-10 00:50:39 +00:00
console_video.h Two changes: 2008-01-09 18:03:40 +00:00
iax2-parser.c Start untangling header inclusion in a way that does not affect 2007-11-16 20:04:58 +00:00
iax2-parser.h Merged revisions 75445 via svnmerge from 2007-07-17 20:49:09 +00:00
iax2-provision.c HUGE improvements to QoS/CoS handling by IgorG 2007-12-16 10:51:53 +00:00
iax2-provision.h Don't reload a configuration file if nothing has changed. 2007-08-16 21:09:46 +00:00
iax2.h Doxygen updates, formatting. 2007-12-11 22:20:22 +00:00
misdn_config.c Merged revisions 100930 via svnmerge from 2008-01-29 17:42:48 +00:00
vcodecs.c prevent a panic when destroying a channel with no incoming video. 2008-01-01 23:54:40 +00:00
vgrabbers.c The fixes in this commit are mainly to allow compiling of trunk with --enable-dev-mode, mutex profiling, lock debugging, etc. Mainly, the version.c needs to be in the OBJS line; asterisk.h was chosen to have the prototypes for ast_get_version, ast_get_version_num; and the ASTERISK_FILE_VERSION macro needs to be used after including asterisk.h in a few files. I hope I did the right thing. If not, let me know. 2008-01-10 00:50:39 +00:00