On Feb 16, 2010 at 12:47, marius zbihlei marius.zbihlei@1and1.ro wrote:
Hello
In cfg/cfg_ctx.c : 888 there is the definition of the function cfg_get_by_name which gets called in case of a "sercmd cfg.get" command
... if (var->def->on_change_cb) { /* The variable cannot be retrieved, because the fixup function may have changed it, and it is better to return an error than an incorrect value */ return 1; } ...
The "problem" is that if a use a fixup callback(or a on_change callback) , this function returns an error and the value cannot be read anymore via sercmd. What is the best way to proceed in this case? I am currently working on the modules_k/registrar module and if STATISTICS are used (default in kamailio build), I need to register some callbacks to be called when sercmd cfg.set_now_int (set_delayed_int) are called so I update kamailio's statistics framework with the new values passed from ser cfg framework. (for example min_expires, max_expires and others)
You need this callback to be called the moment the value is set (1), in each process, before the updated config is used (2) or once, before the updated config is use the 1st time (by the first process that needs to access it) (3)?
If (2) is ok, then use the on_set_child_cb (next field in the cfg_def). If (3) is ok, then set CFG_CB_ONLY_ONCE among the flag and use the on_set_child_cb, like for (2).
Is there a way for the cfg framework to specify that the callback doesn't change the value (like in the case above)?
We could add a new flag (e.g. CFG_NOP_FIXUP or CFG_TRANSPARENT_FIXUP). So far I guess nobody had a fixup that didn't change the value :-)
Any ideas welcome.
In the long run we have to fix somehow the var. w/ fixup unreadable problem. Maybe we should add a cfg_on_display callback (but then we would have to update a lot of cfg_defs).
Andrei