summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-03-13 10:21:13 +0000
committerDaniel Golle2026-03-14 00:29:08 +0000
commit2c7c0d2974205a25ae4e4e56b70f38ffdca50cae (patch)
tree2f967314cea24ce04d09c79b762d1b66cea62780
parent5a9b16dd18acbc7676899ad9091eace4e3850d06 (diff)
downloadprocd-2c7c0d2974205a25ae4e4e56b70f38ffdca50cae.tar.gz
rcS: avoid duplicate pending "running" calls
Since those can be triggered by instance restarts now, and since the calls can wait for their service to be active, suppress duplicate concurrent script calls in case of rapid consecutive crashes. Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit 891094aefcb28a376a43b7c539f599a8e0987e4d)
-rw-r--r--rcS.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rcS.c b/rcS.c
index 2851fae..bfaf50b 100644
--- a/rcS.c
+++ b/rcS.c
@@ -125,6 +125,16 @@ static void q_initd_complete(struct runqueue *q, struct runqueue_task *p)
free(s);
}
+static bool find_runqueue_list_entry(struct list_head *list, char *file, char *param)
+{
+ struct initd *s;
+
+ list_for_each_entry(s, list, proc.task.list.list)
+ if (!strcmp(s->file, file) && !strcmp(s->param, param))
+ return true;
+ return false;
+}
+
static void add_initd(struct runqueue *q, char *file, char *param)
{
static const struct runqueue_task_type initd_type = {
@@ -135,6 +145,11 @@ static void add_initd(struct runqueue *q, char *file, char *param)
struct initd *s;
char *p, *f;
+ if (!strcmp(param, "running") &&
+ (find_runqueue_list_entry(&q->tasks_active.list, file, param) ||
+ find_runqueue_list_entry(&q->tasks_inactive.list, file, param)))
+ return;
+
s = calloc_a(sizeof(*s), &f, strlen(file) + 1, &p, strlen(param) + 1);
if (!s) {
ERROR("Out of memory in %s.\n", file);