qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Joel Stanley" <joel@jms.id.au>, "Kevin Wolf" <kwolf@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-arm@nongnu.org, "Eric Blake" <eblake@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Michael Roth" <michael.roth@amd.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	"Fam Zheng" <fam@euphon.net>, "Hanna Reitz" <hreitz@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>
Subject: [PULL 07/25] win32/socket: introduce qemu_socket_unselect() helper
Date: Mon, 13 Mar 2023 15:43:17 +0400	[thread overview]
Message-ID: <20230313114335.424093-8-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20230313114335.424093-1-marcandre.lureau@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

A more explicit version of qemu_socket_select() with no events.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-8-marcandre.lureau@redhat.com>
---
 include/sysemu/os-win32.h | 2 ++
 io/channel-socket.c       | 4 ++--
 util/oslib-win32.c        | 7 ++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index 9f842ae643..504a8966c3 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -169,6 +169,8 @@ static inline void qemu_funlockfile(FILE *f)
 bool qemu_socket_select(SOCKET s, WSAEVENT hEventObject,
                         long lNetworkEvents, Error **errp);
 
+bool qemu_socket_unselect(SOCKET s, Error **errp);
+
 /* We wrap all the sockets functions so that we can
  * set errno based on WSAGetLastError()
  */
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 0bc29c4808..03757c7a7e 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -442,7 +442,7 @@ static void qio_channel_socket_finalize(Object *obj)
             }
         }
 #ifdef WIN32
-        qemu_socket_select(ioc->fd, NULL, 0, NULL);
+        qemu_socket_unselect(ioc->fd, NULL);
 #endif
         closesocket(ioc->fd);
         ioc->fd = -1;
@@ -846,7 +846,7 @@ qio_channel_socket_close(QIOChannel *ioc,
 
     if (sioc->fd != -1) {
 #ifdef WIN32
-        qemu_socket_select(sioc->fd, NULL, 0, NULL);
+        qemu_socket_unselect(sioc->fd, NULL);
 #endif
         if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
             socket_listen_cleanup(sioc->fd, errp);
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index df752fc762..dbd32acc98 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -180,7 +180,7 @@ static int socket_error(void)
 void qemu_socket_set_block(int fd)
 {
     unsigned long opt = 0;
-    qemu_socket_select(fd, NULL, 0, NULL);
+    qemu_socket_unselect(fd, NULL);
     ioctlsocket(fd, FIONBIO, &opt);
 }
 
@@ -298,6 +298,11 @@ bool qemu_socket_select(SOCKET s, WSAEVENT hEventObject,
     return true;
 }
 
+bool qemu_socket_unselect(SOCKET s, Error **errp)
+{
+    return qemu_socket_select(s, NULL, 0, errp);
+}
+
 #undef connect
 int qemu_connect_wrap(int sockfd, const struct sockaddr *addr,
                       socklen_t addrlen)
-- 
2.39.2



  parent reply	other threads:[~2023-03-13 11:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 11:43 [PULL 00/25] Win socket patches marcandre.lureau
2023-03-13 11:43 ` [PULL 01/25] util: drop qemu_fork() marcandre.lureau
2023-03-13 11:43 ` [PULL 02/25] tests: use closesocket() marcandre.lureau
2023-03-13 11:43 ` [PULL 03/25] io: " marcandre.lureau
2023-03-13 11:43 ` [PULL 04/25] tests: add test-error-report marcandre.lureau
2023-03-13 11:43 ` [PULL 05/25] error: add global &error_warn destination marcandre.lureau
2023-03-13 11:43 ` [PULL 06/25] win32/socket: introduce qemu_socket_select() helper marcandre.lureau
2023-03-13 11:43 ` marcandre.lureau [this message]
2023-03-13 11:43 ` [PULL 08/25] aio: make aio_set_fd_poll() static to aio-posix.c marcandre.lureau
2023-03-13 11:43 ` [PULL 09/25] aio/win32: aio_set_fd_handler() only supports SOCKET marcandre.lureau
2023-03-13 11:43 ` [PULL 10/25] main-loop: remove qemu_fd_register(), win32/slirp/socket specific marcandre.lureau
2023-03-13 11:43 ` [PULL 11/25] slirp: unregister the win32 SOCKET marcandre.lureau
2023-03-13 11:43 ` [PULL 12/25] slirp: open-code qemu_socket_(un)select() marcandre.lureau
2023-03-13 11:43 ` [PULL 13/25] win32: avoid mixing SOCKET and file descriptor space marcandre.lureau
2023-03-13 11:43 ` [PULL 14/25] os-posix: remove useless ioctlsocket() define marcandre.lureau
2023-03-13 11:43 ` [PULL 15/25] win32: replace closesocket() with close() wrapper marcandre.lureau
2023-03-13 11:43 ` [PULL 16/25] tests: fix path separator, use g_build_filename() marcandre.lureau
2023-03-13 11:43 ` [PULL 17/25] char: do not double-close fd when failing to add client marcandre.lureau
2023-03-13 11:43 ` [PULL 18/25] tests/docker: fix a win32 error due to portability marcandre.lureau
2023-03-13 11:43 ` [PULL 19/25] osdep: implement qemu_socketpair() for win32 marcandre.lureau
2023-03-13 11:43 ` [PULL 20/25] qmp: 'add_client' actually expects sockets marcandre.lureau
2023-03-13 11:43 ` [PULL 21/25] monitor: release the lock before calling close() marcandre.lureau
2023-03-13 11:43 ` [PULL 22/25] qmp: add 'get-win32-socket' marcandre.lureau
2023-03-13 11:43 ` [PULL 23/25] libqtest: make qtest_qmp_add_client work on win32 marcandre.lureau
2023-03-13 11:43 ` [PULL 24/25] qtest: enable vnc-display test " marcandre.lureau
2023-03-13 11:43 ` [PULL 25/25] QMP/HMP: only actually implement getfd on CONFIG_POSIX marcandre.lureau
2023-03-13 11:45 ` [PULL 00/25] Win socket patches Marc-André Lureau
2023-03-13 11:53 ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230313114335.424093-8-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=joel@jms.id.au \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).