aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2022-08-08 11:39:32 +0100
committerGitHub <noreply@github.com>2022-08-08 11:39:32 +0100
commitff0ef3fb1ed7b206d0586071a88778110b245582 (patch)
tree06abf5d247c137dcfa45231f286bd1518d1e1ab7 /lib
parent1305f161b7e0dd2c2a420c17efcb0bd49b94dad4 (diff)
downloadlibvfio-user-ff0ef3fb1ed7b206d0586071a88778110b245582.zip
libvfio-user-ff0ef3fb1ed7b206d0586071a88778110b245582.tar.gz
libvfio-user-ff0ef3fb1ed7b206d0586071a88778110b245582.tar.bz2
delete socket on vfu_ctx_destroy (#702)
fixes #660 Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c2
-rw-r--r--lib/tran_sock.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 5ce5767..3b3f9a6 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -1637,7 +1637,6 @@ vfu_destroy_ctx(vfu_ctx_t *vfu_ctx)
vfu_log(vfu_ctx, LOG_WARNING, "failed to reset context: %m");
}
- free(vfu_ctx->uuid);
free(vfu_ctx->pci.config_space);
if (vfu_ctx->tran->fini != NULL) {
@@ -1651,6 +1650,7 @@ vfu_destroy_ctx(vfu_ctx_t *vfu_ctx)
free_regions(vfu_ctx);
free(vfu_ctx->migration);
free(vfu_ctx->irqs);
+ free(vfu_ctx->uuid);
free(vfu_ctx);
}
diff --git a/lib/tran_sock.c b/lib/tran_sock.c
index b894fb3..7c4e30b 100644
--- a/lib/tran_sock.c
+++ b/lib/tran_sock.c
@@ -414,6 +414,7 @@ tran_sock_init(vfu_ctx_t *vfu_ctx)
ret = listen(ts->listen_fd, 0);
if (ret < 0) {
ret = errno;
+ (void) unlink(vfu_ctx->uuid);
}
out:
@@ -651,10 +652,13 @@ tran_sock_fini(vfu_ctx_t *vfu_ctx)
ts = vfu_ctx->tran_data;
- if (ts != NULL && ts->listen_fd != -1) {
- // FIXME: handle EINTR
- (void) close(ts->listen_fd);
- ts->listen_fd = -1;
+ if (ts != NULL) {
+ (void) unlink(vfu_ctx->uuid);
+ if (ts->listen_fd != -1) {
+ // FIXME: handle EINTR
+ (void) close(ts->listen_fd);
+ ts->listen_fd = -1;
+ }
}
free(vfu_ctx->tran_data);