diff --git a/ubusd_main.c b/ubusd_main.c index 14d3be2..ce20009 100644 --- a/ubusd_main.c +++ b/ubusd_main.c @@ -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; @@ -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 */