fix infinite loop on client poll
authorFelix Fietkau <nbd@nbd.name>
Sun, 19 Nov 2023 14:39:59 +0000 (15:39 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 19 Nov 2023 14:39:59 +0000 (15:39 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
client.c

index 1fc90d8496cf10f79f36d7435c4cf81401d4c4bf..11d1c527c87abfce9c522f6126c63a39747fc539 100644 (file)
--- a/client.c
+++ b/client.c
@@ -224,12 +224,12 @@ static void client_fd_cb(struct uloop_fd *fd, unsigned int events)
        pfd = (int *)CMSG_DATA(cmsg);
        msg.msg_controllen = cmsg->cmsg_len;
 
+retry:
        if (fd->eof) {
                client_free(cl);
                return;
        }
 
-retry:
        iov.iov_base = &cl->rx_buf;
        iov.iov_len = min_sz;
        if (!cl->rx_ofs) {
@@ -239,6 +239,8 @@ retry:
                len = recvmsg(fd->fd, &msg, 0);
                if (len < 0)
                        return;
+               if (!len)
+                       fd->eof = true;
 
                cl->rx_ofs = len;
                cl->rx_fd = *pfd;