Merge qio 2018-06-28 v3

Misc bug fixes for sockets channels
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJbNNaPAAoJEL6G67QVEE/fkaIP/0uzsFYO4FnAXvAYH9kwPaVG
 +YX1UKu4M5gt9Zz3SouLbTSyu3muAmS2IRHXGHjzMSLQVSvInt/iik7DGSKM8kLg
 GBouq1XX1U49/+HaF+ffEj8D3aY0F0zkirokbioDobH+67TjLAXRi7dtccQFn8qH
 Q4mDq7MEv1AI4JHgdN88wniPlMpn6/otk9Pt5LN27Cs6Zmy094HnvqnWiBku8QLk
 /Ck3z6AA6Tlltpvayy1Ugzv88MksFJioMiJxeCSoEm4IOgIwkJrcsnMnRHt+JmYo
 IKdw7QdC1eFq9TJmaOm2Wf81KhH9vpL8azSqVV+xNwgnYzeJR0KeuDPink6C+ygK
 JAYKhzFG/sccd7Ercvir8i2BG86s6k2DtK59NRLwnpnQEZ9DidX3hAA4cK16Ef3X
 iIbbHjMvBiZjO7uGlpLjSM8W7zzbRM7qbC2pIxsMhmTOgbXbSldiK1IK8olTOE4b
 ePuEiD2lMY8We3sVmCX+OvKu7vrNv4cK7gKm9Z1zdH0L8CxCFdUQB/EsEHG4mY7G
 PhbTcBvGgaRIrH3ngqyodNqQUu/k10HvLq/skTxSzKA5AIp2XSC35+hPNKI/AvJF
 rnNQdO40Yt5bGPg3Uz+5J8vWXzQgywB9UWSurDGiw7lWMBT1cZbAI2xxJ2nxETf+
 ufS2sUTr/WKVVMcA8b0K
 =fAyo
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging

Merge qio 2018-06-28 v3

Misc bug fixes for sockets channels

# gpg: Signature made Thu 28 Jun 2018 13:37:35 BST
# gpg:                using RSA key BE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/qio-next-pull-request:
  Delete AF_UNIX socket after close
  socket: don't free msgfds if error equals EAGAIN

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-06-28 17:53:31 +01:00
commit 609ef9f451
2 changed files with 19 additions and 3 deletions

View file

@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
s->write_msgfds,
s->write_msgfds_num);
/* free the written msgfds, no matter what */
if (s->write_msgfds_num) {
/* free the written msgfds in any cases other than errno==EAGAIN */
if (EAGAIN != errno && s->write_msgfds_num) {
g_free(s->write_msgfds);
s->write_msgfds = 0;
s->write_msgfds_num = 0;

View file

@ -685,8 +685,10 @@ qio_channel_socket_close(QIOChannel *ioc,
Error **errp)
{
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
int rc = 0;
if (sioc->fd != -1) {
SocketAddress *addr = socket_local_address(sioc->fd, errp);
#ifdef WIN32
WSAEventSelect(sioc->fd, NULL, 0);
#endif
@ -697,8 +699,22 @@ 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 0;
return rc;
}
static int