Skip to content

Commit

Permalink
Merge pull request #74 from jestabro/last-in-prioqueue
Browse files Browse the repository at this point in the history
configdep: T5660: add marker for last element of priority queues
  • Loading branch information
dmbaturin authored Feb 29, 2024
2 parents f3e579e + 2411564 commit b1d6f52
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cli_cstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 11 additions & 0 deletions src/cli_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/commit/commit-algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit b1d6f52

Please sign in to comment.