[asterisk-dev] [Code Review] 4297: config: Add option to NOT preserve the effective context when changing a template.

George Joseph reviewboard at asterisk.org
Sun Dec 28 19:22:24 CST 2014

This is an automatically generated e-mail. To reply, visit:

Review request for Asterisk Developers.

Repository: Asterisk


Let's say you have a template T with variable VAR1 = ON and you have a context C(T) that doesn't specify VAR1.  If you read C, the effective value of VAR1 is ON.  Now you change T VAR1 to OFF and call ast_config_text_file_save.  The current behavior is that the file gets re-written with T/VAR1=OFF but C/VAR1=ON is added.  Personally, I think this is a bug. It's preserving the effective state of C even though I didn't specify C/VAR1 in th first place.  I believe the behavior should be that if I didn't specify C/VAR1 originally, then the effective value of C/VAR1 should continue to follow the inherited state.  Now, if I DID explicitly specify C/VAR1, the it should be preserved even if the template changes.

Even though I think the existing behavior is a bug, it's been that way forever so I'm not changing it.  Instead, I've created ast_config_text_file_save2() that takes a bitmask of quirks, one of which is to preserve the effective context (the current behavior).  The original ast_config_text_file_save calls *2 with the preserve quirk.  If you want the new behavior, call *2 directly without a quirk.

I've also updated Manager UpdateConfig with a new parameter 'PreserveEffectiveContext' whose default is 'yes'.  If you want the new behavior with UpdateConfig, set 'PreserveEffectiveContext: no'.


  branches/13/main/manager.c 430144 
  branches/13/main/config.c 430144 
  branches/13/include/asterisk/config.h 430144 

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


This is tough to test with unit tests but the existing TestSuite manager/config tests check the existing behavior and they still pass.  I've also added a new no_preserve_effective_context test to manager/config that tests the new behavior.


George Joseph

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

More information about the asterisk-dev mailing list