diff options
author | June McEnroe <june@causal.agency> | 2019-08-01 14:43:58 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-08-01 14:43:58 -0400 |
commit | c1407c47b6c507c22152a95006da66f3a095034d (patch) | |
tree | f59eea6f64b9212589acb10d427371aa41c6b0b3 | |
parent | Be silent about client errors (diff) | |
download | stream-c1407c47b6c507c22152a95006da66f3a095034d.tar.gz stream-c1407c47b6c507c22152a95006da66f3a095034d.zip |
Add poll timeout to ingest
-rw-r--r-- | ingest.c | 10 |
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"); } |