summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-08-01 14:43:58 -0400
committerJune McEnroe <june@causal.agency>2019-08-01 14:43:58 -0400
commitc1407c47b6c507c22152a95006da66f3a095034d (patch)
treef59eea6f64b9212589acb10d427371aa41c6b0b3
parentBe silent about client errors (diff)
downloadstream-c1407c47b6c507c22152a95006da66f3a095034d.tar.gz
stream-c1407c47b6c507c22152a95006da66f3a095034d.zip
Add poll timeout to ingest
-rw-r--r--ingest.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ingest.c b/ingest.c
index 3fb5e40..1dfae36 100644
--- a/ingest.c
+++ b/ingest.c
@@ -56,7 +56,14 @@ int main(void) {
 		{ .events = POLLIN, .fd = STDIN_FILENO },
 		{ .events = POLLIN, .fd = server },
 	};
-	while (0 < poll(fds, 2, -1)) {
+	for (;;) {
+		int nfds = poll(fds, 2, 60 * 1000);
+		if (nfds < 0) err(EX_IOERR, "poll");
+
+		if (!nfds) {
+			// TODO: Increment idle time in info.
+		}
+
 		if (fds[0].revents) {
 			char buf[4096];
 			ssize_t rlen = read(STDIN_FILENO, buf, sizeof(buf));
@@ -106,5 +113,4 @@ int main(void) {
 			assert(client == maxClient);
 		}
 	}
-	err(EX_IOERR, "poll");
 }