[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] util/log: do not close and reopen log files when flags are t
From: |
Greg Kurz |
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 |
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;
> > >
> > >
> >
> >