From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.cs.Stanford.EDU (smtp2.cs.stanford.edu [171.64.64.26]) by dpdk.org (Postfix) with ESMTP id 177ED2904 for ; Wed, 12 Oct 2016 23:18:16 +0200 (CEST) Received: from mail-io0-f178.google.com ([209.85.223.178]:33299) by smtp2.cs.Stanford.EDU with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84_2) (envelope-from ) id 1buQuk-0007tr-O2 for dev@dpdk.org; Wed, 12 Oct 2016 14:18:15 -0700 Received: by mail-io0-f178.google.com with SMTP id q192so64706946iod.0 for ; Wed, 12 Oct 2016 14:18:14 -0700 (PDT) X-Gm-Message-State: AA6/9Rm2TF/O+X7X2e5OtyxbHBkEwKZvloBSI1SIyFlh/jsiWzAm76jHEVP01EHS+qmRaTWoLk0NaE8F33E3dA== X-Received: by 10.107.7.135 with SMTP id g7mr3626886ioi.15.1476307094413; Wed, 12 Oct 2016 14:18:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.98.67 with HTTP; Wed, 12 Oct 2016 14:17:33 -0700 (PDT) In-Reply-To: <2906824.LEp5vtMuTD@xps13> References: <20160928204244.8288-1-ouster@cs.stanford.edu> <20161012193832.5016-1-ouster@cs.stanford.edu> <2906824.LEp5vtMuTD@xps13> From: John Ousterhout Date: Wed, 12 Oct 2016 14:17:33 -0700 X-Gmail-Original-Message-ID: Message-ID: To: Thomas Monjalon Cc: dev@dpdk.org X-Spam-Score: -1.0 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin on smtp2.cs.Stanford.EDU X-Scan-Signature: fba5d1bf4e2735531ca2f657cf1136db Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v4] log: respect rte_openlog_stream calls before rte_eal_init X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 21:18:16 -0000 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 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"? >