diff options
| author | Felix Fietkau | 2023-11-27 12:16:34 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2023-11-27 12:16:35 +0000 |
| commit | cfd83ccc1e4ea4cf442bf65ac22d55caf5cb3910 (patch) | |
| tree | 7c80cc5436040a72880b467b43352dd7281ca18e | |
| parent | a2301fa3b0c6c7914e059ceb875a6f3f6fe67954 (diff) | |
server: properly handle unclaimed file descriptors
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | client.c | 7 | ||||
| -rw-r--r-- | ring.c | 1 |
2 files changed, 8 insertions, 0 deletions
@@ -199,6 +199,12 @@ static void client_parse_message(struct client *cl) DC(3, cl, "Invalid message type %d", msg->type); break; } + + if (cl->rx_fd < 0) + return; + + close(cl->rx_fd); + cl->rx_fd = -1; } static void client_fd_cb(struct uloop_fd *fd, unsigned int events) @@ -225,6 +231,7 @@ static void client_fd_cb(struct uloop_fd *fd, unsigned int events) msg.msg_controllen = cmsg->cmsg_len; retry: + *pfd = -1; if (fd->eof) { client_free(cl); return; @@ -64,6 +64,7 @@ struct client_ring *client_ring_alloc(struct client *cl) r->cl = cl; r->id = msg->id; r->fd = cl->rx_fd; + cl->rx_fd = -1; r->ring_size = msg->ring_size; r->data_size = msg->data_size; list_add_tail(&r->list, &cl->bufs); |