switch (msg->type) {
case CL_MSG_RING_ADD:
client_ring_alloc(cl);
+ client_send_msg(cl, msg, -1);
break;
case CL_MSG_RING_REMOVE:
DC(2, cl, "delete ring %x", msg->id);
client_ring_free(r);
else
DC(2, cl, "ring not found");
+ client_send_msg(cl, msg, -1);
break;
case CL_MSG_RING_NOTIFY:
DC(3, cl, "notify on ring %d", msg->id);
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)
pfd = (int *)CMSG_DATA(cmsg);
msg.msg_controllen = cmsg->cmsg_len;
+retry:
+ *pfd = -1;
if (fd->eof) {
client_free(cl);
return;
}
-retry:
iov.iov_base = &cl->rx_buf;
iov.iov_len = min_sz;
if (!cl->rx_ofs) {
len = recvmsg(fd->fd, &msg, 0);
if (len < 0)
return;
+ if (!len)
+ fd->eof = true;
cl->rx_ofs = len;
cl->rx_fd = *pfd;