From: Uri Lublin <uril@redhat.com>
To: Mark McLoughlin <markmc@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] migrate_fd_close: delete associated io-handler before closing the fd
Date: Mon, 08 Jun 2009 20:02:25 +0300 [thread overview]
Message-ID: <4A2D4421.4020206@redhat.com> (raw)
In-Reply-To: <1244479094.3632.60.camel@blaa>
On 06/08/2009 07:38 PM, Mark McLoughlin wrote:
>
> Would the below patch working equally well? But then again, we should
> really remove the I/O handler before closing the fd.
I think it should work too.
My patch does remove the I/O handler before closing the fd.
>
> (The close(s->fd) in migration_fd_cleanup() looks like it can never
> happen - perhaps we should remove it)
Perhaps we should. I think it's like a "plan b" in case qemu_fclose did not
actually closed the file descriptor (which, as you mentioned, currently, can
never happen).
> diff --git a/migration.c b/migration.c
> index 401383c..078967f 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -154,13 +154,21 @@ void migrate_fd_error(FdMigrationState *s)
>
> void migrate_fd_cleanup(FdMigrationState *s)
> {
> - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
Would it be safer to keep the I/O handler deletion before the call to
qemu_fclose (in addition to adding the one below), or it does not matter.
> + int fd;
> +
> + /* qemu_fclose() can cause I/O to be flushed (see buffered_close())
> + * which, in turn, can cause an I/O handler to be registered. We
> + * need to delay removing the I/O handler until after qemu_fclose().
> + */
> + fd = s->fd;
>
> if (s->file) {
> dprintf("closing file\n");
> qemu_fclose(s->file);
> }
>
> + qemu_set_fd_handler2(fd, NULL, NULL, NULL, NULL);
> +
> if (s->fd != -1)
> close(s->fd);
>
>
Regards,
Uri.
prev parent reply other threads:[~2009-06-08 17:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 11:28 [Qemu-devel] [PATCH] migrate_fd_close: delete associated io-handler before closing the fd Uri Lublin
2009-06-08 15:49 ` Mark McLoughlin
2009-06-08 15:56 ` Uri Lublin
2009-06-08 16:38 ` Mark McLoughlin
2009-06-08 17:02 ` Uri Lublin [this message]
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=4A2D4421.4020206@redhat.com \
--to=uril@redhat.com \
--cc=markmc@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.