summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-03-13 10:21:13 +0000
committerFelix Fietkau2025-03-13 10:21:15 +0000
commit891094aefcb28a376a43b7c539f599a8e0987e4d (patch)
tree178937e6b2229af4f6c48acd8f94b2390b206087
parent80187cf5badb43ec42f6025acaeb70688c494101 (diff)
downloadprocd-891094aefcb28a376a43b7c539f599a8e0987e4d.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>
-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);