Introduction
Introduction Statistics Contact Development Disclaimer Help
pselect: set a timeout of 1 second - teed - A multiplex relay tee(1) daemon.
git clone git://bitreich.org/teed git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d…
Log
Files
Refs
Tags
README
LICENSE
---
commit 8d1db0f43e921b998a06dd61d1442220db29ee89
parent 18db7808b4a41155537b83db1294720403990b4c
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 14 Aug 2023 14:22:16 +0200
pselect: set a timeout of 1 second
This is for sockets that are closed. These are signalled by FD_ISSET and a
read() that returns 0. This way it can handle them directly when it occurs vs
on the next read of a socket.
Signed-off-by: Christoph Lohmann <[email protected]>
Diffstat:
M teed.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/teed.c b/teed.c
@@ -161,6 +161,7 @@ main(int argc, char *argv[])
llist *wfds, *rfds, *lfds, *e, *qe;
socklen_t saddrlen, cltlen;
fd_set fdset;
+ struct timespec timeout;
initsignals();
@@ -210,6 +211,8 @@ main(int argc, char *argv[])
lfds = llist_put(lfds, &lfd, sizeof(lfd));
}
+ timeout.tv_sec = 1;
+ timeout.tv_nsec = 0;
for (;;) {
maxsfd = 0;
FD_ZERO(&fdset);
@@ -224,7 +227,7 @@ main(int argc, char *argv[])
maxsfd = *(int *)e->data;
}
- if (pselect(maxsfd+1, &fdset, NULL, NULL, NULL, NULL) < 0) {
+ if (pselect(maxsfd+1, &fdset, NULL, NULL, &timeout, NULL) < 0)…
if (errno == EINTR)
continue;
perror("pselect");
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.