aboutsummaryrefslogtreecommitdiff
path: root/lib/tran_sock.c
diff options
context:
space:
mode:
authorswapnili <swapnil.ingle@nutanix.com>2020-12-07 11:26:50 +0100
committerGitHub <noreply@github.com>2020-12-07 11:26:50 +0100
commitf0fdfa8936dc908e024202aa9bfc203cd3d3c816 (patch)
treec4fa8aff01bc19e6b7b9cbf5ef03e7fe47e50f80 /lib/tran_sock.c
parent331de08bd97d97433655fafd681b2d278e5d9d8d (diff)
downloadlibvfio-user-f0fdfa8936dc908e024202aa9bfc203cd3d3c816.zip
libvfio-user-f0fdfa8936dc908e024202aa9bfc203cd3d3c816.tar.gz
libvfio-user-f0fdfa8936dc908e024202aa9bfc203cd3d3c816.tar.bz2
Remove sock_flags from struct vfu_ctx (#163)
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib/tran_sock.c')
-rw-r--r--lib/tran_sock.c10
1 files changed, 5 insertions, 5 deletions
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;
}