qemu-char: do not operate on sources from finalize callbacks
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Apr 2013 15:32:09 +0000 (17:32 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 22 Apr 2013 13:52:21 +0000 (08:52 -0500)
commit2b316774f60291f57ca9ecb6a9f0712c532cae34
treefdf4cd08dc4b74c11778d4f4d7fcf141775ff2f1
parentcdbf6e165988ab9d7c01da03b9e27bb8ac0c76aa
qemu-char: do not operate on sources from finalize callbacks

Due to a glib bug, the finalize callback is called with the GMainContext
lock held.  Thus, any operation on the context from the callback will
cause recursive locking and a deadlock.  This happens, for example,
when a client disconnects from a socket chardev.

The fix for this is somewhat ugly, because we need to forego polymorphism
and implement our own function to destroy IOWatchPoll sources.  The
right thing to do here would be child sources, but we support older
glib versions that do not have them.  Not coincidentially, glib developers
found and fixed the deadlock as part of implementing child sources.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Message-id: 1366385529-10329-5-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-char.c