]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
qemu-char: another io_add_watch_poll fix
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Apr 2013 13:23:27 +0000 (15:23 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 15 Apr 2013 15:22:05 +0000 (10:22 -0500)
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>
Message-id: 1365600207-21685-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-char.c

index eae17fc61cc6c8080c810a0f8e4ffc2e2dd7b436..90cc1d6fbea5af388d08617db5a4123287687a30 100644 (file)
@@ -663,6 +663,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;
@@ -671,7 +672,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;
 }
 
 #ifndef _WIN32