diff options
author | John Levon <john.levon@nutanix.com> | 2021-04-06 10:35:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 10:35:37 +0100 |
commit | 6c9e6a86dbf3e5c6ec2932358ca2c352bdcba5c8 (patch) | |
tree | 6e5f74d2ca14d2f8a8a9245eba9f2cf546500f0e /lib/tran_sock.c | |
parent | 7edb594733a42698b30511a84ad1ac34dbafd3b4 (diff) | |
download | libvfio-user-6c9e6a86dbf3e5c6ec2932358ca2c352bdcba5c8.zip libvfio-user-6c9e6a86dbf3e5c6ec2932358ca2c352bdcba5c8.tar.gz libvfio-user-6c9e6a86dbf3e5c6ec2932358ca2c352bdcba5c8.tar.bz2 |
->get_request(): return failure if not connected (#411)
Previously, we'd end up doing a recvmsg(-1, ...), which would fail anyway, but
it's best to be explicit.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/tran_sock.c')
-rw-r--r-- | lib/tran_sock.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/tran_sock.c b/lib/tran_sock.c index 0faa2ea..a0fe931 100644 --- a/lib/tran_sock.c +++ b/lib/tran_sock.c @@ -755,6 +755,11 @@ tran_sock_get_request(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr, ts = vfu_ctx->tran_data; + if (ts->conn_fd == -1) { + vfu_log(vfu_ctx, LOG_ERR, "%s: not connected", __func__); + return -ENOTCONN; + } + /* * TODO ideally we should set O_NONBLOCK on the fd so that the syscall is * faster (?). I tried that and get short reads, so we need to store the |