summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-08-15 09:53:03 -0400
committerJune McEnroe <june@causal.agency>2020-08-15 09:53:03 -0400
commitf39d916e3a35527eb0d886506ac6fc70fa639070 (patch)
tree0fb74809fd14dbc03cf07fe7907fc3277ce186e2
parentReap children (diff)
downloadcatsit-f39d916e3a35527eb0d886506ac6fc70fa639070.tar.gz
catsit-f39d916e3a35527eb0d886506ac6fc70fa639070.zip
Just use CLOCK_MONOTONIC and clean up includes
CLOCK_MONOTONIC exists everywhere.
-rw-r--r--daemon.c19
-rw-r--r--daemon.h2
-rw-r--r--service.c2
3 files changed, 12 insertions, 11 deletions
diff --git a/daemon.c b/daemon.c
index cd12f92..9eb8bb4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -29,7 +29,6 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <sys/timespec.h>
 #include <sys/wait.h>
 #include <sysexits.h>
 #include <syslog.h>
@@ -266,7 +265,7 @@ int main(int argc, char *argv[]) {
 		struct timespec now = {0};
 		struct timespec timeout = {0};
 		if (timespecisset(&deadline)) {
-			clock_gettime(CLOCK_MONOTONIC_FAST, &now);
+			clock_gettime(CLOCK_MONOTONIC, &now);
 			timespecsub(&deadline, &now, &timeout);
 		}
 		if (timeout.tv_sec < 0 || timeout.tv_nsec < 0) {
@@ -281,13 +280,15 @@ int main(int argc, char *argv[]) {
 
 		// TODO: Handle FIFO and pipes.
 
-		clock_gettime(CLOCK_MONOTONIC_FAST, &now);
-		for (size_t i = 0; i < services.len; ++i) {
-			struct Service *service = &services.ptr[i];
-			if (service->intent != Start) continue;
-			if (service->state == Start) continue;
-			if (timespeccmp(&service->restartDeadline, &now, <=)) {
-				serviceStart(service);
+		if (timespecisset(&deadline)) {
+			clock_gettime(CLOCK_MONOTONIC, &now);
+			for (size_t i = 0; i < services.len; ++i) {
+				struct Service *service = &services.ptr[i];
+				if (service->intent != Start) continue;
+				if (service->state == Start) continue;
+				if (timespeccmp(&service->restartDeadline, &now, <=)) {
+					serviceStart(service);
+				}
 			}
 		}
 
diff --git a/daemon.h b/daemon.h
index 4a9f4d8..db82ee2 100644
--- a/daemon.h
+++ b/daemon.h
@@ -19,7 +19,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/timespec.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 typedef unsigned char byte;
diff --git a/service.c b/service.c
index 35d15f3..12f465f 100644
--- a/service.c
+++ b/service.c
@@ -111,7 +111,7 @@ err:
 }
 
 static void setDeadline(struct Service *service) {
-	clock_gettime(CLOCK_MONOTONIC_FAST, &service->restartDeadline);
+	clock_gettime(CLOCK_MONOTONIC, &service->restartDeadline);
 	timespecadd(
 		&service->restartDeadline, &service->restartInterval,
 		&service->restartDeadline
generate.sh?id=55728948b94a17b99fabeb1c61d20c5ef18c7f73&follow=1'>Allow not having descriptionsJune McEnroe I'm sorry, I can't keep writing descriptions. It makes posting photos take too long, I often don't know the words for what I'm looking at, and a good description is an entirely different work of art than the photo I took, and I'm just a photographer. It's visual art. 2024-09-23Automatically select the last used lens for a bodyJune McEnroe 2024-09-19Add photos from September 5June McEnroe Had to prefix the folder number onto these file names manually because they must have come out of a different scanner or something. 2024-09-15Add some more film stocks to the listJune McEnroe 2024-09-13Add photos from September 2June McEnroe 2024-09-13Add Fomapan 200 to films listJune McEnroe 2024-09-10Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe This seems easier to visually scan. The only other thing I'd like is a nicer date rendering but JavaScript is useless for that. 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe