From: Greg Kurz <groug@kaod.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: Re: [PATCH] util/log: do not close and reopen log files when flags are turned off
Date: Wed, 26 Oct 2022 08:27:22 +0200 [thread overview]
Message-ID: <20221026082722.1368f5c8@bahia> (raw)
In-Reply-To: <CABgObfZcmAr6S7zMK3N86gnpobL-=aS1mSW6yVitz3t2Va2h7g@mail.gmail.com>
On Tue, 25 Oct 2022 22:27:36 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il mar 25 ott 2022, 16:39 Greg Kurz <groug@kaod.org> ha scritto:
>
> > > > - if (logfile && (!need_to_open_file || changed_name)) {
> > > > - qatomic_rcu_set(&global_file, NULL);
> >
> > Hmm... wait, shouldn't this NULLifying be performed...
> >
> > > > - if (logfile != stderr) {
> > > > + if (logfile) {
> > > > + fflush(logfile);
> > > > + if (changed_name && logfile != stderr) {
> > > > RCUCloseFILE *r = g_new0(RCUCloseFILE, 1);
> > > > r->fd = logfile;
> >
> >
> > ... here since we the following closes the global_file ?
> >
> > > > call_rcu(r, rcu_close_file, rcu);
> >
>
> Yes it should.
>
I'll fix this when I repost the full series.
Cheers,
--
Greg
> Paolo
>
> > > + logfile = NULL;
> > > > }
> > > > - logfile = NULL;
> > > > }
> > > >
> > > > if (!logfile && need_to_open_file) {
> > > > if (filename) {
> > > > - logfile = fopen(filename, log_append ? "a" : "w");
> > > > + logfile = fopen(filename, "w");
> > > > if (!logfile) {
> > > > error_setg_errno(errp, errno, "Error opening logfile
> > %s",
> > > > filename);
> > > > @@ -290,8 +289,6 @@ static bool qemu_set_log_internal(const char
> > *filename, bool changed_name,
> > > > logfile = stderr;
> > > > }
> > > >
> > > > - log_append = 1;
> > > > -
> > > > qatomic_rcu_set(&global_file, logfile);
> > > > }
> > > > return true;
> > >
> > >
> >
> >
prev parent reply other threads:[~2022-10-26 6:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 9:21 [PATCH] util/log: do not close and reopen log files when flags are turned off Paolo Bonzini
2022-10-25 10:30 ` Richard Henderson
2022-10-25 12:33 ` Greg Kurz
2022-10-25 14:38 ` Greg Kurz
2022-10-25 20:27 ` Paolo Bonzini
2022-10-26 6:27 ` Greg Kurz [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=20221026082722.1368f5c8@bahia \
--to=groug@kaod.org \
--cc=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 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).