[PATCH v3 12/16] slirp: unregister the win32 SOCKET

marcandre.lureau@redhat.com posted 16 patches 2 years, 11 months ago
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>, Jason Wang <jasowang@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Joel Stanley <joel@jms.id.au>, Peter Maydell <peter.maydell@linaro.org>
[PATCH v3 12/16] slirp: unregister the win32 SOCKET
Posted by marcandre.lureau@redhat.com 2 years, 11 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Presumably, this is what should happen when the SOCKET is to be removed.
(it probably worked until now because closesocket() does it implicitly,
but we never now how the slirp library could use the SOCKET later)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 net/slirp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/slirp.c b/net/slirp.c
index 0730a935ba..a7c35778a6 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -259,7 +259,9 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
 
 static void net_slirp_unregister_poll_fd(int fd, void *opaque)
 {
-    /* no qemu_fd_unregister */
+#ifdef WIN32
+    qemu_socket_unselect(fd, NULL);
+#endif
 }
 
 static void net_slirp_notify(void *opaque)
-- 
2.39.2


Re: [PATCH v3 12/16] slirp: unregister the win32 SOCKET
Posted by Stefan Berger 2 years, 11 months ago

On 2/21/23 07:47, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Presumably, this is what should happen when the SOCKET is to be removed.
> (it probably worked until now because closesocket() does it implicitly,
> but we never now how the slirp library could use the SOCKET later)
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   net/slirp.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index 0730a935ba..a7c35778a6 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -259,7 +259,9 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
> 
>   static void net_slirp_unregister_poll_fd(int fd, void *opaque)
>   {
> -    /* no qemu_fd_unregister */
> +#ifdef WIN32
The majority of code seems to use _WIN32. Not sure what is 'right'.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>

> +    qemu_socket_unselect(fd, NULL);
> +#endif
>   }
> 
>   static void net_slirp_notify(void *opaque)

Re: [PATCH v3 12/16] slirp: unregister the win32 SOCKET
Posted by Marc-André Lureau 2 years, 11 months ago
Hi

On Thu, Mar 2, 2023 at 10:45 PM Stefan Berger <stefanb@linux.ibm.com> wrote:

>
>
> On 2/21/23 07:47, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Presumably, this is what should happen when the SOCKET is to be removed.
> > (it probably worked until now because closesocket() does it implicitly,
> > but we never now how the slirp library could use the SOCKET later)
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   net/slirp.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/slirp.c b/net/slirp.c
> > index 0730a935ba..a7c35778a6 100644
> > --- a/net/slirp.c
> > +++ b/net/slirp.c
> > @@ -259,7 +259,9 @@ static void net_slirp_register_poll_fd(int fd, void
> *opaque)
> >
> >   static void net_slirp_unregister_poll_fd(int fd, void *opaque)
> >   {
> > -    /* no qemu_fd_unregister */
> > +#ifdef WIN32
> The majority of code seems to use _WIN32. Not sure what is 'right'.
>
>
Both should be correct. I think I like the "WIN32" version better though
(see also
https://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c
)


> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
>
>
thanks


> > +    qemu_socket_unselect(fd, NULL);
> > +#endif
> >   }
> >
> >   static void net_slirp_notify(void *opaque)
>
>