qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-char: another io_add_watch_poll fix
@ 2013-04-10 13:23 Paolo Bonzini
  2013-04-10 17:59 ` Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Paolo Bonzini @ 2013-04-10 13:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: amit.shah, aliguori

After attaching the source, we have to remove the reference we hold
to it, because we do not hold anymore a pointer to the source.

If we do not do this, removing the source will not finalize it and
will not drop the "real" I/O watch source.

This showed up when backporting the new flow control patches to older
versions of QEMU that still used select.  The whole select then failed
with EBADF (poll instead will reporting POLLNVAL on a single pollfd)
and QEMU froze.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index 37117b5..2caef56 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -610,6 +610,7 @@ static guint io_add_watch_poll(GIOChannel *channel,
                                gpointer user_data)
 {
     IOWatchPoll *iwp;
+    int tag;
 
     iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll));
     iwp->fd_can_read = fd_can_read;
@@ -618,7 +619,9 @@ static guint io_add_watch_poll(GIOChannel *channel,
     iwp->fd_read = (GSourceFunc) fd_read;
     iwp->src = NULL;
 
-    return g_source_attach(&iwp->parent, NULL);
+    tag = g_source_attach(&iwp->parent, NULL);
+    g_source_unref(&iwp->parent);
+    return tag;
 }
 
 static GIOChannel *io_channel_from_fd(int fd)
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-04-17 16:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 13:23 [Qemu-devel] [PATCH] qemu-char: another io_add_watch_poll fix Paolo Bonzini
2013-04-10 17:59 ` Amit Shah
2013-04-11  8:58   ` Paolo Bonzini
2013-04-12  9:24     ` Amit Shah
2013-04-12 10:31       ` Paolo Bonzini
2013-04-15 21:10 ` Anthony Liguori
2013-04-16  9:15 ` Gerd Hoffmann
2013-04-16  9:34   ` Paolo Bonzini
2013-04-17 15:36     ` Hans de Goede
2013-04-17 16:54       ` Paolo Bonzini

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).