From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDd1P-0006YH-SY for qemu-devel@nongnu.org; Mon, 08 Jun 2009 07:28:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDd1K-0006Ro-Is for qemu-devel@nongnu.org; Mon, 08 Jun 2009 07:28:10 -0400 Received: from [199.232.76.173] (port=58096 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDd1K-0006Rh-DM for qemu-devel@nongnu.org; Mon, 08 Jun 2009 07:28:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36593) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDd1J-0005Bw-CP for qemu-devel@nongnu.org; Mon, 08 Jun 2009 07:28:06 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n58BS3ul018230 for ; Mon, 8 Jun 2009 07:28:04 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n58BS3S6017569 for ; Mon, 8 Jun 2009 07:28:03 -0400 Received: from localhost.localdomain (dhcp-1-187.tlv.redhat.com [10.35.1.187]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n58BS137007421 for ; Mon, 8 Jun 2009 07:28:02 -0400 From: Uri Lublin Date: Mon, 8 Jun 2009 14:28:01 +0300 Message-Id: <1244460481-13575-1-git-send-email-uril@redhat.com> Subject: [Qemu-devel] [PATCH] migrate_fd_close: delete associated io-handler before closing the fd List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org It may happen that the io-handler is still registered. That causes select() to return with EBADF, not calling handlers for other fds. The io-handler would be registered when (on the source) the whole state was written but not yet flushed. For example when using QEMUFileBuffered, (tcp-migration) there may be data left in a buffer waiting to be transferred. In such a case buffered_close() calls buffered_flush() which calls migrate_fd_put_buffer, which may, upon EAGAIN, register migrate_fd_put_notify as a handler. Signed-off-by: Uri Lublin --- migration.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/migration.c b/migration.c index 401383c..57f2a52 100644 --- a/migration.c +++ b/migration.c @@ -301,5 +301,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque) int migrate_fd_close(void *opaque) { FdMigrationState *s = opaque; + + qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); return s->close(s); } -- 1.6.2.2