From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0582A00BE; Wed, 29 Apr 2020 01:14:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9287C1D63E; Wed, 29 Apr 2020 01:14:29 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id A66A71D62C for ; Wed, 29 Apr 2020 01:14:26 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id r14so142030pfg.2 for ; Tue, 28 Apr 2020 16:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ly2vdLIY8STcYSrGHWZteL8D1u99js7jHHLKIZdSHuI=; b=x598tCidydSQuE6SVwpow0nyIp9W5toi6TKOsubhb/UQmfZQKXgptiymy86frqyeo+ EOPpvCWdZi7T1JrvJA4XTDHWOwQte7i1t2juCAavkh4Aq+GwR/CmLxeoiVLnKXydpp3W g8AC7VY0eDimxaJ9wfRNftsfj+7qiThIOWf586rc2JOj/T8V0OyrzMVpKf0jKrWJ375n vutPqFnDx7Oc0G80CVNJz4GoeAzlfoUiCbotmBNhbAIFIfnl2LnGTzXkO/ie7OrRGp/W MWcmdp639m8viDpoi5BFL2t9hupJAE0fyzRVVCKda/9OC5e9uaHbjgw8bgHXLJ/IPAkU D6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ly2vdLIY8STcYSrGHWZteL8D1u99js7jHHLKIZdSHuI=; b=l1+jL5cGsRJzKXeUuGNcXAM2QaXSB2ygzsqJJjT8rvrMIkp1Y+dcjYlAJqOKXCtKPp FHEd4HG4ivmjFRG1iI5oWV8lb/RurGK85pjdvfbW7c1LztrcRWNj005WCQ46gTwmXyeB FDiejVcH70RsX0StaL+5cGLOZn1kuFoWs91+GKNphEeQi8nAiu0UKDWpdURm9cLgxsEC PGksfq0Ca/N/JlrnMOHoFmYYat1ev5I77d4c7Pp4uvp5jQqIPPA+7rpoak3t+eiJY7o+ e7dlxdV+rCOsfbN3hhYeQOPrU8ITIXnuu3vhZGRrbebo+saMg72NZCfDWUpsHaBa/3xg p4AA== X-Gm-Message-State: AGi0Pua3RBvPwKMAH4YuNi/O28TQK+/4s+9HhifxLmgZy4wb2SoIq1Uw z3NU6uhow6BaVU8lIv2NNcND4CMHoMudGQ== X-Google-Smtp-Source: APiQypL5f+YAlu9xLqT9VK6PAUAQX6hLtrdm/PoMh1h7LY0qi6fQl605GufyCnSc6K8ikhdIRu/xWA== X-Received: by 2002:a63:b952:: with SMTP id v18mr30526496pgo.179.1588115665371; Tue, 28 Apr 2020 16:14:25 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:24 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:14:08 -0700 Message-Id: <20200428231415.17985-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/8] eal: log: close on cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When application calls rte_eal_cleanup on shutdown, the DPDK log should be closed and cleaned up. Fixes: af75078fece3 ("first public release") Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/eal_common_log.c | 12 ++++++++++++ lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linux/eal.c | 1 + lib/librte_eal/linux/eal_log.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index d7a5f9b6417a..43de798ae96a 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -479,3 +479,15 @@ eal_log_set_default(FILE *default_log) "Debug dataplane logs available - lower performance\n"); #endif } + +/* + * Called by environment-specific cleanup function. + */ +void +eal_log_cleanup(void) +{ + if (default_log_stream) { + fclose(default_log_stream); + default_log_stream = NULL; + } +} diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index ecf827914fdd..24ddfc6c53f4 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -89,6 +89,12 @@ int rte_eal_memzone_init(void); */ void eal_log_set_default(FILE *default_log); +/** + * Common log cleanup function (private to eal). + * Closes the default log stream. Called from rte_eal_cleanup(). + */ +void eal_log_cleanup(void); + /** * Fill configuration with number of physical and logical processors * @@ -150,6 +156,13 @@ int rte_eal_timer_init(void); */ int rte_eal_log_init(const char *id, int facility); +/** + * Close the default log stream + * + * This function is private to EAL. + */ +void rte_eal_log_cleanup(void); + /** * Save the log regexp for later */ diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index aa72d3650929..73d2c98b012b 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1337,6 +1337,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(&internal_config); + rte_eal_log_cleanup(); return 0; } diff --git a/lib/librte_eal/linux/eal_log.c b/lib/librte_eal/linux/eal_log.c index 43c8460bfb07..c407cb3c0edb 100644 --- a/lib/librte_eal/linux/eal_log.c +++ b/lib/librte_eal/linux/eal_log.c @@ -37,8 +37,16 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size) return ret; } +static int +console_log_close(__attribute__((unused)) void *c) +{ + closelog(); + return 0; +} + static cookie_io_functions_t console_log_func = { .write = console_log_write, + .close = console_log_close, }; /* @@ -60,3 +68,9 @@ rte_eal_log_init(const char *id, int facility) return 0; } + +void +rte_eal_log_cleanup(void) +{ + eal_log_cleanup(); +} -- 2.20.1