mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
io: ensure UNIX client doesn't unlink server socket
The qio_channel_socket_close method for was mistakenly unlinking the
UNIX server socket, even if the channel was a client connection. This
was not noticed with chardevs, since they never call close, but with the
VNC server, this caused the VNC server socket to be deleted after the
first client quit.
The qio_channel_socket_close method also needlessly reimplemented the
logic that already exists in socket_listen_cleanup(). Just call that
method directly, for listen sockets only.
This fixes a regression introduced in QEMU 3.0.0 with
commit d66f78e1ea
Author: Pavel Balaev <mail@void.so>
Date: Mon May 21 19:17:35 2018 +0300
Delete AF_UNIX socket after close
Fixes launchpad #1795100
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
6d809e7da9
commit
73564c407c
2 changed files with 80 additions and 25 deletions
|
@ -688,10 +688,13 @@ qio_channel_socket_close(QIOChannel *ioc,
|
|||
int rc = 0;
|
||||
|
||||
if (sioc->fd != -1) {
|
||||
SocketAddress *addr = socket_local_address(sioc->fd, errp);
|
||||
#ifdef WIN32
|
||||
WSAEventSelect(sioc->fd, NULL, 0);
|
||||
#endif
|
||||
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
|
||||
socket_listen_cleanup(sioc->fd, errp);
|
||||
}
|
||||
|
||||
if (closesocket(sioc->fd) < 0) {
|
||||
sioc->fd = -1;
|
||||
error_setg_errno(errp, errno,
|
||||
|
@ -699,20 +702,6 @@ qio_channel_socket_close(QIOChannel *ioc,
|
|||
return -1;
|
||||
}
|
||||
sioc->fd = -1;
|
||||
|
||||
if (addr && addr->type == SOCKET_ADDRESS_TYPE_UNIX
|
||||
&& addr->u.q_unix.path) {
|
||||
if (unlink(addr->u.q_unix.path) < 0 && errno != ENOENT) {
|
||||
error_setg_errno(errp, errno,
|
||||
"Failed to unlink socket %s",
|
||||
addr->u.q_unix.path);
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr) {
|
||||
qapi_free_SocketAddress(addr);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue