From 74b6ce43e3aacbb101018407196fc963e2c39fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 16 Jun 2016 21:28:52 +0200 Subject: socket: unlink unix socket on remove MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qemu leaves unix socket files behind when removing a listening chardev or leaving. qemu could clean that up, even if doing so isn't race-free. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1347077 Signed-off-by: Marc-André Lureau Message-Id: <1466105332-10285-4-git-send-email-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- io/channel-socket.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'io/channel-socket.c') diff --git a/io/channel-socket.c b/io/channel-socket.c index 1cd58487b0..6ec87f8cdb 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -400,7 +400,17 @@ static void qio_channel_socket_init(Object *obj) static void qio_channel_socket_finalize(Object *obj) { QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(obj); + if (ioc->fd != -1) { + if (QIO_CHANNEL(ioc)->features & QIO_CHANNEL_FEATURE_LISTEN) { + Error *err = NULL; + + socket_listen_cleanup(ioc->fd, &err); + if (err) { + error_report_err(err); + err = NULL; + } + } #ifdef WIN32 WSAEventSelect(ioc->fd, NULL, 0); #endif -- cgit v1.2.3