From e3d388fffe8e0cfa37587032bd480592d2ff1905 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 28 Feb 2024 08:26:24 -0600 Subject: configdep: T5660: add marker for last element of priority queues (cherry picked from commit 2411564dead4a27d155a13973e8fd4b438546dce) --- src/cli_cstore.h | 2 ++ src/cli_objects.c | 11 +++++++++++ src/commit/commit-algorithm.cpp | 4 ++++ 3 files changed, 17 insertions(+) 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", -- cgit v1.2.3 From bd9a4fab9cf02a2aa2e33b5a4fba970308491ea0 Mon Sep 17 00:00:00 2001 From: khramshinr Date: Tue, 9 Apr 2024 19:52:47 +0800 Subject: configdep: T6206 fix marker for last element of delete priority queues related task: T5660: add marker for last element of priority queues (cherry picked from commit 5183b6fd34e4a9a5443406e801ec70139e68c471) --- src/commit/commit-algorithm.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commit/commit-algorithm.cpp b/src/commit/commit-algorithm.cpp index ab7eee6..a84fdf5 100644 --- a/src/commit/commit-algorithm.cpp +++ b/src/commit/commit-algorithm.cpp @@ -1308,6 +1308,8 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2) TRACE_INIT("Processing the Priority Queue"); clear_last(); int num = pq.size(); + // decrease by one because we have one root element + --num; while (!dpq.empty()) { PrioNode *p = dpq.top(); set_if_last(num+dpq.size()); -- cgit v1.2.3