[dpdk-dev] [PATCH v4] log: respect rte_openlog_stream calls before rte_eal_init
John Ousterhout
ouster at cs.stanford.edu
Wed Oct 12 23:17:33 CEST 2016
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 at 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"?
>
More information about the dev
mailing list