Il mar 25 ott 2022, 16:39 Greg Kurz <[email protected]> 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.
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;
> >
> >
>
>