Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ubusd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,17 @@ static void client_cb(struct uloop_fd *sock, unsigned int events)
}

bytes = recvmsg(sock->fd, &msghdr, 0);
if (bytes < 0)
if (bytes <= 0)
goto out;

if (*pfd >= 0)
cl->pending_msg_fd = *pfd;

cl->pending_msg_offset += bytes;
if (cl->pending_msg_offset < (int) sizeof(cl->hdrbuf))
goto out;
if (cl->pending_msg_offset < (int) sizeof(cl->hdrbuf)) {
/* Keep draining; edge-triggered uloop may not fire again. */
goto retry;
}

if (blob_raw_len(&cl->hdrbuf.data) < sizeof(struct blob_attr))
goto disconnect;
Expand Down Expand Up @@ -179,7 +181,8 @@ static void client_cb(struct uloop_fd *sock, unsigned int events)

if (bytes < len) {
cl->pending_msg_offset += bytes;
goto out;
/* Keep draining; edge-triggered uloop may not fire again. */
goto retry;
}

/* accept message */
Expand Down
Loading