usock: fix poll return code check
authorFelix Fietkau <nbd@nbd.name>
Wed, 8 Mar 2023 08:38:53 +0000 (09:38 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 8 Mar 2023 08:38:55 +0000 (09:38 +0100)
errno needs to be compared against EINTR/EAGAIN instead of the return code,
and only if the return code is < 0.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
usock.c

diff --git a/usock.c b/usock.c
index 0ce5390434d2ccae31bd0d9ec49c7e74e2e47c23..15b6988e3c6d8269eb6fde2c085d3eccc6349c22 100644 (file)
--- a/usock.c
+++ b/usock.c
@@ -120,10 +120,7 @@ static int poll_restart(struct pollfd *fds, int nfds, int timeout)
 
        while (1) {
                ret = poll(fds, nfds, timeout);
-               if (ret == EAGAIN)
-                       continue;
-
-               if (ret != EINTR)
+               if (ret >= 0 || (errno != EINTR && errno != EAGAIN))
                        return ret;
 
                clock_gettime(CLOCK_MONOTONIC, &cur);