summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-02-28 08:26:24 -0600
committerJohn Estabrook <jestabro@vyos.io>2024-02-28 08:31:39 -0600
commit2411564dead4a27d155a13973e8fd4b438546dce (patch)
tree2bfd7327e66fdda5408f0308ea22c48cbca232bf
parentf3e579ecae206f58447d25196c3495496b7693a5 (diff)
downloadvyatta-cfg-2411564dead4a27d155a13973e8fd4b438546dce.tar.gz
vyatta-cfg-2411564dead4a27d155a13973e8fd4b438546dce.zip
configdep: T5660: add marker for last element of priority queues
-rw-r--r--src/cli_cstore.h2
-rw-r--r--src/cli_objects.c11
-rw-r--r--src/commit/commit-algorithm.cpp4
3 files changed, 17 insertions, 0 deletions
diff --git a/src/cli_cstore.h b/src/cli_cstore.h
index b77d69c..3ef7f72 100644
--- a/src/cli_cstore.h
+++ b/src/cli_cstore.h
@@ -142,6 +142,8 @@ int restore_output(void);
/* functions from cli_objects */
char *get_at_string(void);
void set_in_commit(boolean b);
+void set_if_last(int);
+void clear_last(void);
void set_at_string(char* s);
void set_in_delete_action(boolean b);
diff --git a/src/cli_objects.c b/src/cli_objects.c
index 190ff46..c09c368 100644
--- a/src/cli_objects.c
+++ b/src/cli_objects.c
@@ -34,6 +34,7 @@ static first_seg f_seg_m;
static char *in_commit_file = "/var/tmp/in_commit";
static char *initial_file = "/var/tmp/initial_in_commit";
+static char *last_in_queue_file = "/var/tmp/last_in_queue";
static int mark_by_file(char *p) {
int ret = mknod(p, S_IFREG|0664, 0);
@@ -96,6 +97,16 @@ void set_in_commit(boolean b) {
}
}
+void set_if_last(int n) {
+ if (n == 1) {
+ mark_by_file(last_in_queue_file);
+ }
+}
+
+void clear_last(void) {
+ remove_mark(last_in_queue_file);
+}
+
boolean is_in_exec(void) {
return in_exec;
}
diff --git a/src/commit/commit-algorithm.cpp b/src/commit/commit-algorithm.cpp
index f04b8c2..ab7eee6 100644
--- a/src/commit/commit-algorithm.cpp
+++ b/src/commit/commit-algorithm.cpp
@@ -1306,8 +1306,11 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2)
debug_on = !!getenv("VYOS_DEBUG");
TRACE_INIT("Processing the Priority Queue");
+ clear_last();
+ int num = pq.size();
while (!dpq.empty()) {
PrioNode *p = dpq.top();
+ set_if_last(num+dpq.size());
if (!_commit_exec_prio_subtree(cs, p)) {
// prio subtree failed
OUTPUT_USER("delete [ %s ] failed\n",
@@ -1321,6 +1324,7 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2)
}
while (!pq.empty()) {
PrioNode *p = pq.top();
+ set_if_last(pq.size());
if (!_commit_exec_prio_subtree(cs, p)) {
// prio subtree failed
OUTPUT_USER("[[%s]] failed\n",