summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--service.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/service.c b/service.c
index 3472151..ef4834a 100644
--- a/service.c
+++ b/service.c
@@ -22,7 +22,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/time.h>
 #include <syslog.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "daemon.h"
@@ -107,14 +109,24 @@ err:
 
 void serviceStart(struct Service *service) {
 	if (service->state == Start) return;
-	service->intent = Start;
-	// TODO: Reset restart interval.
 
+	if (service->intent == Start) {
+		struct timespec backoff = service->restartInterval;
+		timespecadd(&backoff, &backoff, &service->restartInterval);
+	} else {
+		service->restartInterval = restartInterval;
+	}
+	clock_gettime(CLOCK_MONOTONIC_FAST, &service->restartDeadline);
+	timespecadd(
+		&service->restartDeadline, &service->restartInterval,
+		&service->restartDeadline
+	);
+
+	service->intent = Start;
 	service->pid = fork();
 	if (service->pid < 0) {
 		syslog(LOG_ERR, "fork: %m");
 		return;
-		// FIXME: Do we treat this as a restart condition?
 	}
 	if (service->pid) {
 		service->state = Start;
0'>2018-11-13Add gzgetc.3June McEnroe 2018-11-13Add gzputc.3June McEnroe 2018-11-13Add gzgets.3June McEnroe 2018-11-13Add gzputs.3June McEnroe 2018-11-13Add gzprintf.3June McEnroe 2018-11-13Add gzfwrite.3June McEnroe 2018-11-13Add gzwrite.3June McEnroe 2018-11-12Add gzfread.3June McEnroe 2018-11-12Add gzread.3June McEnroe 2018-11-12Add gzsetparams.3June McEnroe 2018-11-12Add gzbuffer.3June McEnroe 2018-11-12Add gzdopen to gzopen.3June McEnroe 2018-11-12Add gzopen.3June McEnroe 2018-11-12Add inflateBackEnd.3June McEnroe 2018-11-12Add inflateBack.3June McEnroe 2018-11-12Add inflateBackInit.3June McEnroe 2018-11-11Add inflateGetHeader.3June McEnroe 2018-11-11Add inflateMark.3June McEnroe 2018-11-11Add inflatePrime.3June McEnroe 2018-11-11Add inflateReset.3June McEnroe 2018-11-11Add inflateCopy.3June McEnroe 2018-11-11Add inflateSync.3June McEnroe 2018-11-11Add inflateGetDictionary.3June McEnroe 2018-11-11Add inflateSetDictionary.3June McEnroe 2018-11-11Add inflateInit2.3June McEnroe