[asterisk-dev]
bug 6002, new Algorithm for merge_contexts_and_delete
Steve Murphy
murf at digium.com
Thu Mar 1 12:01:52 MST 2007
I want folks to review this before I implement it. Hate to do all this
work,
and end up with a lemon.
Please read bug 6002, which was introduced by rizzo last year, and try
to understand the shortcomings of the current merge_contexts_and_delete,
when it comes to regcontext; and see if the below algorithm will meet
the needs.
I've posted the text below to bug 6002, but I think it would be good to
have the community as a whole review the proposed algorithm, and let me
know if it's flawed.
(Also, it won't hurt to look at bug 8574-- Call processing stops while
reloading
large dialpan)
OK, been looking at the code. I have to add one more requirement to
merge_contexts_and_delete: that it hold the locks for less than a frame
time. Since the freeing and destruction of list elements is the most
time-consuming part of the operation, (or, at least, WAS), I propose
this algorithm:
4 lists are involved:
1. the list of contexts to merge into the dialplan (extcontexts)
2. the existing contexts (contexts)
3. a list containing extens to free
4. a list containing just contexts to free
The algorithm would go something like this:
1. get the conlock & hintlock
2. preserve the watchers as before
3. traverse the dp, and unlink all exten/prio that match registrar.
Do Not
remove any contexts (yet). Unlink them from the contexts list,
and
link them instead to the list of extens to free.
4. traverse the dp again, and for any empty contexts, that match
registrar,
unlink from contexts, and link to the contexts to free list. this
and #3
might be tied into a single traversal.
5. Now, for each context in extcontexts, search for a match in
contexts.
(THIS MAKES ME NERVOUS IF THE DP IS BIG!)
if found:
either the context or something in it has a different
registrar.
go thru the contexts entry, and relink the exten/prios into the
matching extcontext's entry. If there are exten
collisions, (THIS SEARCH MAKES ME NERVOUS IF THE DP IS BIG!)
then take all the contexts prios for that exten, and insert
them into
the collided extcontexts exten. Issue a warning only if there
are
collisions. Keep the extcontexts version. After all the prios
are
merged, then put the contexts exten into the free list.
Now, Move the now empty contexts' context into the free context
list.
Then move the merged context into the contexts list from the
extcontext list.
if not found:
link the context from extcontexts to contexts. This is the
"quick and
easy" path.
6. Restore the watchers, as is now being done.
7. Unlock the above locks,
8. Destroy the stuff in the to-be-freed lists
9. Return.
This will keep the regcontexts. If the dp is big, or the extcontexts
big, this
operation will run dangerously slow! Having O(1) search times for all 3
types of search (context, exten, prio) would be a big plus.
Will this be sufficient? The key is getting part 5 right.
--
Steve Murphy
Software Developer
Digium
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3227 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20070301/f1b2c9ec/smime.bin
More information about the asterisk-dev
mailing list