diff options
| author | Christian Hopps <chopps@labn.net> | 2024-02-21 00:16:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-21 00:16:47 -0500 |
| commit | 37588ece04ae6cc9e100225f02caa16717ab3b7d (patch) | |
| tree | 8bf9cd0e0dfd7492f997c19123df66e7c0f593a7 /lib/northbound.c | |
| parent | 605009d7298f959210643e7074d40e973f1266d7 (diff) | |
| parent | 01f371a677dc52ff888b14360f6ffd63b91f3845 (diff) | |
Merge pull request #15401 from idryzhov/fix-nb-crash
Fix order of NB callbacks (and a crash)
Diffstat (limited to 'lib/northbound.c')
| -rw-r--r-- | lib/northbound.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/northbound.c b/lib/northbound.c index a3d91e56af..6b31b818c5 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -391,11 +391,14 @@ void nb_config_replace(struct nb_config *config_dst, static inline int nb_config_cb_compare(const struct nb_config_cb *a, const struct nb_config_cb *b) { - /* Sort by priority first. */ + /* + * Sort by priority first. If the operation is "destroy", reverse the + * order, so that the dependencies are destroyed before the dependants. + */ if (a->nb_node->priority < b->nb_node->priority) - return -1; + return a->operation != NB_CB_DESTROY ? -1 : 1; if (a->nb_node->priority > b->nb_node->priority) - return 1; + return a->operation != NB_CB_DESTROY ? 1 : -1; /* * Preserve the order of the configuration changes as told by libyang. |
