All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Ousterhout <ouster@cs.stanford.edu>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v4] log: respect rte_openlog_stream calls before rte_eal_init
Date: Wed, 12 Oct 2016 14:17:33 -0700	[thread overview]
Message-ID: <CAGXJAmzc+MkM0T6RbFZ7mAqZzhakV9aUs-GB9JCyGQP8njmEGg@mail.gmail.com> (raw)
In-Reply-To: <2906824.LEp5vtMuTD@xps13>

Suppose an application starts up, calls rte_eal_init, then later on invokes
code like this:

fclose(stderr);
stderr = fopen("foo", "w");

This might happen if it is using stderr for its log, but decides to roll
the log over to a new file.

Now stderr has changed.  However, if DPDK made a copy of it with a
statement like this:

FILE *default_log_stream = stderr;

then default_log_stream will continue to refer to the old log file, not the
new one.

Thus, it's better to grab the value of stderr at the last possible moment
before logging.

-John-

On Wed, Oct 12, 2016 at 12:47 PM, Thomas Monjalon <thomas.monjalon@6wind.com
> wrote:

> 2016-10-12 12:38, John Ousterhout:
> > @@ -127,6 +125,19 @@ rte_vlog(uint32_t level, uint32_t logtype, const
> char *format, va_list ap)
> >  {
> >       int ret;
> >       FILE *f = rte_logs.file;
> > +     if (f == NULL) {
> > +             f = default_log_stream;
> > +             if (f == NULL) {
> > +                     /*
> > +                      * Grab the current value of stderr here, rather
> than
> > +                      * just initializing default_log_stream to stderr.
> This
> > +                      * ensures that we will always use the current
> value
> > +                      * of stderr, even if the application closes and
> > +                      * reopens it.
> > +                      */
> > +                     f = stderr;
> > +             }
> > +     }
>
> I don't understand this big comment.
> What is the difference with initializing default_log_stream to stderr?
> What do you mean by "if the application closes and reopens it"?
>

  reply	other threads:[~2016-10-12 21:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 20:42 [PATCH] log: respect rte_openlog_stream calls before rte_eal_init John Ousterhout
2016-09-30 15:01 ` Thomas Monjalon
2016-10-10 22:39 ` [PATCH v2] " John Ousterhout
2016-10-11  8:08   ` Thomas Monjalon
2016-10-11 16:30     ` John Ousterhout
2016-10-11 20:30       ` Thomas Monjalon
2016-10-11 21:46         ` John Ousterhout
2016-10-12  7:09           ` Thomas Monjalon
2016-10-11 22:16       ` Don Provan
2016-10-12  0:22         ` John Ousterhout
2016-10-12 19:29 ` [PATCH v3] " John Ousterhout
2016-10-12 19:38 ` [PATCH v4] " John Ousterhout
2016-10-12 19:47   ` Thomas Monjalon
2016-10-12 21:17     ` John Ousterhout [this message]
2016-10-13 20:03   ` Thomas Monjalon

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=CAGXJAmzc+MkM0T6RbFZ7mAqZzhakV9aUs-GB9JCyGQP8njmEGg@mail.gmail.com \
    --to=ouster@cs.stanford.edu \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.com \
    /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.