From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzkG7-0001mB-TM for qemu-devel@nongnu.org; Thu, 27 Oct 2016 08:58:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzkG4-00006s-BR for qemu-devel@nongnu.org; Thu, 27 Oct 2016 08:58:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzkG4-00006T-5a for qemu-devel@nongnu.org; Thu, 27 Oct 2016 08:58:12 -0400 From: "Daniel P. Berrange" Date: Thu, 27 Oct 2016 14:57:31 +0200 Message-Id: <20161027125738.19357-5-berrange@redhat.com> In-Reply-To: <20161027125738.19357-1-berrange@redhat.com> References: <20161027125738.19357-1-berrange@redhat.com> Subject: [Qemu-devel] [PULL v1 04/11] io: set LISTEN flag explicitly for listen sockets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , "Daniel P. Berrange" The SO_ACCEPTCONN ioctl is not portable across OS, with some BSD versions and OS-X not supporting it. There is no viable alternative to this, so instead just set the feature explicitly when creating a listener socket. The current users of qio_channel_socket_new_fd() won't ever be given a listening socket, so there's no problem with no auto-detecting it in this scenario Signed-off-by: Daniel P. Berrange --- io/channel-socket.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index 75cbca3..d7e03f6 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -72,9 +72,6 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc, int fd, Error **errp) { - int val; - socklen_t len = sizeof(val); - if (sioc->fd != -1) { error_setg(errp, "Socket is already open"); return -1; @@ -110,10 +107,6 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc, qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS); } #endif /* WIN32 */ - if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &val, &len) == 0 && val) { - QIOChannel *ioc = QIO_CHANNEL(sioc); - qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN); - } return 0; @@ -220,6 +213,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc, close(fd); return -1; } + qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN); return 0; } -- 2.9.3