Syslib: Add support for setting parameters without global notification

This commit is contained in:
Lorenz Meier 2015-02-14 20:31:51 +01:00
parent bed3eaafa1
commit aef041e032
2 changed files with 20 additions and 4 deletions

View File

@ -361,7 +361,7 @@ param_get(param_t param, void *val)
}
static int
param_set_internal(param_t param, const void *val, bool mark_saved)
param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes)
{
int result = -1;
bool params_changed = false;
@ -436,7 +436,7 @@ out:
* If we set something, now that we have unlocked, go ahead and advertise that
* a thing has been set.
*/
if (params_changed)
if (params_changed && notify_changes)
param_notify_changes();
return result;
@ -445,7 +445,13 @@ out:
int
param_set(param_t param, const void *val)
{
return param_set_internal(param, val, false);
return param_set_internal(param, val, false, true);
}
int
param_set_no_notification(param_t param, const void *val)
{
return param_set_internal(param, val, false, false);
}
int
@ -775,7 +781,7 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
goto out;
}
if (param_set_internal(param, v, state->mark_saved)) {
if (param_set_internal(param, v, state->mark_saved, true)) {
debug("error setting value for '%s'", node->name);
goto out;
}

View File

@ -171,6 +171,16 @@ __EXPORT int param_get(param_t param, void *val);
*/
__EXPORT int param_set(param_t param, const void *val);
/**
* Set the value of a parameter, but do not notify the system about the change.
*
* @param param A handle returned by param_find or passed by param_foreach.
* @param val The value to set; assumed to point to a variable of the parameter type.
* For structures, the pointer is assumed to point to a structure to be copied.
* @return Zero if the parameter's value could be set from a scalar, nonzero otherwise.
*/
__EXPORT int param_set_no_notification(param_t param, const void *val);
/**
* Reset a parameter to its default value.
*