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

Joshua Colp reviewboard at asterisk.org
Tue Dec 30 09:20:04 CST 2014


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



branches/13/include/asterisk/config.h
<https://reviewboard.asterisk.org/r/4297/#comment24566>

    This is picky but we don't use the word "quirk" anywhere else. We generally just refer to them as behavior flags, or flags.



branches/13/main/manager.c
<https://reviewboard.asterisk.org/r/4297/#comment24567>

    'pec' is a poor variable for this because it may end up being other things in the future


- Joshua Colp


On Dec. 29, 2014, 1:22 a.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4297/
> -----------------------------------------------------------
> 
> (Updated Dec. 29, 2014, 1:22 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> 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'.
> 
> 
> Diffs
> -----
> 
>   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/
> 
> 
> Testing
> -------
> 
> 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.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

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


More information about the asterisk-dev mailing list