qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>,
	berrange@redhat.com, "Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PATCH v2 3/3] ui/dbus: fix passing SOCKET to GSocket API & leak
Date: Mon, 20 Mar 2023 17:36:43 +0400	[thread overview]
Message-ID: <20230320133643.1618437-4-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20230320133643.1618437-1-marcandre.lureau@redhat.com>

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

-display dbus is not currently available to win32 users, so it's not
considered a regression.

Note also the close() leak fix in case of error.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/dbus.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ui/dbus.c b/ui/dbus.c
index 0513de9918..b9e9698503 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -304,11 +304,20 @@ dbus_display_add_client(int csock, Error **errp)
         g_cancellable_cancel(dbus_display->add_client_cancellable);
     }
 
+#ifdef WIN32
+    socket = g_socket_new_from_fd(_get_osfhandle(csock), &err);
+#else
     socket = g_socket_new_from_fd(csock, &err);
+#endif
     if (!socket) {
         error_setg(errp, "Failed to setup D-Bus socket: %s", err->message);
+        close(csock);
         return false;
     }
+#ifdef WIN32
+    /* socket owns the SOCKET handle now, so release our osf handle */
+    qemu_close_socket_osfhandle(csock);
+#endif
 
     conn = g_socket_connection_factory_create_connection(socket);
 
-- 
2.39.2



  parent reply	other threads:[~2023-03-20 13:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 13:36 [PATCH v2 0/3] Fix Spice regression on win32 marcandre.lureau
2023-03-20 13:36 ` [PATCH v2 1/3] win32: add qemu_close_socket_osfhandle() marcandre.lureau
2023-03-20 13:42   ` Daniel P. Berrangé
2023-03-20 13:46     ` Marc-André Lureau
2023-03-20 13:52       ` Daniel P. Berrangé
2023-03-20 13:36 ` [PATCH v2 2/3] ui/spice: fix SOCKET handling regression marcandre.lureau
2023-03-20 13:36 ` marcandre.lureau [this message]
2023-03-20 13:42   ` [PATCH v2 3/3] ui/dbus: fix passing SOCKET to GSocket API & leak Daniel P. Berrangé

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=20230320133643.1618437-4-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).