From f0fdfa8936dc908e024202aa9bfc203cd3d3c816 Mon Sep 17 00:00:00 2001 From: swapnili Date: Mon, 7 Dec 2020 11:26:50 +0100 Subject: Remove sock_flags from struct vfu_ctx (#163) Signed-off-by: Swapnil Ingle Reviewed-by: John Levon --- lib/private.h | 2 -- lib/tran_sock.c | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/private.h b/lib/private.h index 9768730..5be90b9 100644 --- a/lib/private.h +++ b/lib/private.h @@ -119,8 +119,6 @@ struct vfu_ctx { /* TODO there should be a void * variable to store transport-specific stuff */ /* VFU_TRANS_SOCK */ - int sock_flags; - int client_max_fds; vfu_reg_info_t *migr_reg; diff --git a/lib/tran_sock.c b/lib/tran_sock.c index a7d6505..a9af65e 100644 --- a/lib/tran_sock.c +++ b/lib/tran_sock.c @@ -94,9 +94,6 @@ init_sock(vfu_ctx_t *vfu_ctx) ret = -errno; goto out; } - vfu_ctx->sock_flags = MSG_DONTWAIT | MSG_WAITALL; - } else { - vfu_ctx->sock_flags = 0; } ret = snprintf(addr.sun_path, sizeof addr.sun_path, "%s", vfu_ctx->uuid); @@ -653,7 +650,7 @@ static int get_request_sock(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, int *fds, size_t *nr_fds) { - int ret; + int ret, sock_flags = 0; struct iovec iov = {.iov_base = hdr, .iov_len = sizeof *hdr}; struct msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1}; struct cmsghdr *cmsg; @@ -668,7 +665,10 @@ get_request_sock(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, * faster (?). I tried that and get short reads, so we need to store the * partially received buffer somewhere and retry. */ - ret = recvmsg(vfu_ctx->conn_fd, &msg, vfu_ctx->sock_flags); + if (vfu_ctx->flags & LIBVFIO_USER_FLAG_ATTACH_NB) { + sock_flags = MSG_DONTWAIT | MSG_WAITALL; + } + ret = recvmsg(vfu_ctx->conn_fd, &msg, sock_flags); if (ret == -1) { return -errno; } -- cgit v1.1