mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
src/confd: refactor commit done hook into a pre and post hook
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
ebc87eb0a0
commit
b319a2df9d
@@ -21,12 +21,18 @@ int core_startup_save(sr_session_ctx_t *session, uint32_t sub_id, const char *mo
|
||||
return SR_ERR_OK;
|
||||
}
|
||||
|
||||
int core_pre_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
|
||||
const char *xpath, sr_event_t event, unsigned request_id, void *priv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run on UPDATE to see how many modules have changes in the inbound changeset
|
||||
* Run on DONE, after the last module callback has run, to activate changes.
|
||||
* For details, see https://github.com/sysrepo/sysrepo/issues/2188
|
||||
*/
|
||||
int core_commit_done(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
|
||||
int core_post_hook(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;
|
||||
|
||||
@@ -73,7 +73,8 @@ struct confd {
|
||||
};
|
||||
|
||||
uint32_t core_hook_prio (void);
|
||||
int core_commit_done (sr_session_ctx_t *, uint32_t, const char *, const char *, sr_event_t, unsigned, void *);
|
||||
int core_pre_hook (sr_session_ctx_t *, uint32_t, const char *, const char *, sr_event_t, unsigned, void *);
|
||||
int core_post_hook (sr_session_ctx_t *, uint32_t, const char *, const char *, sr_event_t, unsigned, void *);
|
||||
int core_startup_save (sr_session_ctx_t *, uint32_t, const char *, const char *, sr_event_t, unsigned, void *);
|
||||
|
||||
static inline int register_change(sr_session_ctx_t *session, const char *module, const char *xpath,
|
||||
@@ -82,6 +83,11 @@ static inline int register_change(sr_session_ctx_t *session, const char *module,
|
||||
struct confd *confd = (struct confd *)arg;
|
||||
int rc;
|
||||
|
||||
if (!flags) {
|
||||
sr_module_change_subscribe(confd->session, module, xpath, core_pre_hook, NULL,
|
||||
0, SR_SUBSCR_PASSIVE, sub);
|
||||
}
|
||||
|
||||
rc = sr_module_change_subscribe(session, module, xpath, cb, arg,
|
||||
CB_PRIO_PRIMARY, flags | SR_SUBSCR_DEFAULT, sub);
|
||||
if (rc) {
|
||||
@@ -97,7 +103,7 @@ static inline int register_change(sr_session_ctx_t *session, const char *module,
|
||||
* the startup-save hook for running -> startup copying.
|
||||
*/
|
||||
if (!flags) {
|
||||
sr_module_change_subscribe(confd->session, module, xpath, core_commit_done, NULL,
|
||||
sr_module_change_subscribe(confd->session, module, xpath, core_post_hook, NULL,
|
||||
core_hook_prio(), SR_SUBSCR_PASSIVE, sub);
|
||||
sr_module_change_subscribe(confd->startup, module, xpath, core_startup_save, NULL,
|
||||
core_hook_prio(), SR_SUBSCR_PASSIVE, sub);
|
||||
|
||||
Reference in New Issue
Block a user