[asterisk-dev] [Code Review] 3326: Sorcery: Do not apply the same wizard to an object type twice; Automatically apply sorcery configuration when sorcery is opened.

Mark Michelson reviewboard at asterisk.org
Fri Mar 14 17:01:15 CDT 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3326/
-----------------------------------------------------------

(Updated March 14, 2014, 10:01 p.m.)


Review request for Asterisk Developers.


Changes
-------

After reading Richard's comment, I investigated tests/test_sorcery.c to see what was up there. Most of the tests failed with my changes. I made a couple of changes

1) I changed the sorcery.conf.sample to use something other than test_sorcery as the category name for the common place that the sorcery tests pull from. This makes the tests still work under their previous assumptions.
2) The caching_wizard_behavior test exposed a bug in my patch. The object_type->wizards container did not have a cmp callback. This test is the only one that attempts to register multiple wizards for an object type. The test to see if the same wizard was being applied multiple times was falsely returning positive because it would always claim success since there was no cmp callback.

This revision of the review addresses the two problems listed above. Unit tests now all pass properly.


Repository: Asterisk


Description
-------

When performing some realtime tests, I noticed that the AMI command PJSIPShowEndpoints was listing all of my endpoints twice. This is because ast_sorcery_apply_config() was being called twice from res_pjsip code, once when initializing system configuration, and once again when initializing the rest of the configuration data. This patch aims to fix the problem on two fronts:

1) Remove the ast_sorcery_apply_config() calls from the PJSIP code entirely in favor of having sorcery automatically apply configuration for the module when sorcery is opened. This reduces the chance of accidentally attempting to apply the same configuration twice. I also removed the call to ast_sorcery_apply_config from res_mwi_external since it is no longer necessary either.

2) Adjust sorcery_apply_wizard_mapping() not to apply the same wizard to an object type more than once, just in case someone does make the error of calling ast_sorcery_apply_config() multiple times for the same object type.


Diffs (updated)
-----

  /branches/12/tests/test_sorcery.c 410606 
  /branches/12/res/res_pjsip/pjsip_configuration.c 410606 
  /branches/12/res/res_pjsip/config_system.c 410606 
  /branches/12/res/res_mwi_external.c 410606 
  /branches/12/main/sorcery.c 410606 
  /branches/12/include/asterisk/sorcery.h 410606 
  /branches/12/configs/sorcery.conf.sample 410606 

Diff: https://reviewboard.asterisk.org/r/3326/diff/


Testing
-------

My tests of retrieving data from realtime now get the expected objects. I don't have any automated tests to post yet because the realtime testsuite is a work in progress.


Thanks,

Mark Michelson

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140314/e42ad66e/attachment-0001.html>


More information about the asterisk-dev mailing list