mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
src/confd: simplify after review comments from wkz
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
c98a99df58
commit
3b3cadd72d
+9
-10
@@ -5,12 +5,10 @@
|
||||
|
||||
static struct confd confd;
|
||||
|
||||
static uint32_t hook_prio = CB_PRIO_PASSIVE;
|
||||
static int num_changes;
|
||||
static int cur_change;
|
||||
|
||||
uint32_t core_hook_prio(void)
|
||||
{
|
||||
static uint32_t hook_prio = CB_PRIO_PASSIVE;
|
||||
|
||||
return hook_prio--;
|
||||
}
|
||||
|
||||
@@ -31,13 +29,17 @@ int core_startup_save(sr_session_ctx_t *session, uint32_t sub_id, const char *mo
|
||||
int core_commit_done(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
|
||||
const char *xpath, sr_event_t event, unsigned request_id, void *priv)
|
||||
{
|
||||
static int num_changes = 0;
|
||||
|
||||
switch (event) {
|
||||
case SR_EV_UPDATE:
|
||||
case SR_EV_CHANGE:
|
||||
num_changes++;
|
||||
return SR_ERR_OK;
|
||||
case SR_EV_ABORT:
|
||||
num_changes = 0;
|
||||
return SR_ERR_OK;
|
||||
case SR_EV_DONE:
|
||||
cur_change++;
|
||||
if (cur_change == num_changes)
|
||||
if (--num_changes == 0)
|
||||
break;
|
||||
return SR_ERR_OK;
|
||||
default:
|
||||
@@ -45,9 +47,6 @@ int core_commit_done(sr_session_ctx_t *session, uint32_t sub_id, const char *mod
|
||||
return SR_ERR_SYS;
|
||||
}
|
||||
|
||||
/* reset for next changeset */
|
||||
num_changes = cur_change = 0;
|
||||
|
||||
/* skip reload in bootstrap, implicit reload in runlevel change */
|
||||
if (systemf("runlevel >/dev/null 2>&1"))
|
||||
return SR_ERR_OK;
|
||||
|
||||
@@ -78,7 +78,6 @@ int core_startup_save (sr_session_ctx_t *, uint32_t, const char *, const ch
|
||||
static inline int register_change(sr_session_ctx_t *session, const char *module, const char *xpath,
|
||||
int flags, sr_module_change_cb cb, void *arg, sr_subscription_ctx_t **sub)
|
||||
{
|
||||
int hook_flags = SR_SUBSCR_UPDATE | SR_SUBSCR_DONE_ONLY | SR_SUBSCR_PASSIVE;
|
||||
struct confd *confd = (struct confd *)arg;
|
||||
int rc;
|
||||
|
||||
@@ -98,9 +97,9 @@ static inline int register_change(sr_session_ctx_t *session, const char *module,
|
||||
*/
|
||||
if (!flags) {
|
||||
sr_module_change_subscribe(confd->session, module, xpath, core_commit_done, NULL,
|
||||
core_hook_prio(), hook_flags, sub);
|
||||
core_hook_prio(), SR_SUBSCR_PASSIVE, sub);
|
||||
sr_module_change_subscribe(confd->startup, module, xpath, core_startup_save, NULL,
|
||||
core_hook_prio(), hook_flags, sub);
|
||||
core_hook_prio(), SR_SUBSCR_PASSIVE, sub);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user