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 7BA6EA00BE; Wed, 29 Apr 2020 01:58:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 006F91D663; Wed, 29 Apr 2020 01:58:41 +0200 (CEST) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id 26A181D659 for ; Wed, 29 Apr 2020 01:58:38 +0200 (CEST) Received: by mail-pj1-f67.google.com with SMTP id a32so7573pje.5 for ; Tue, 28 Apr 2020 16:58:38 -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=GVygkQjjID+OmR+ja6uIzpBhMCRTyyoj3mLawY1JK1s=; b=QCfPb6RREYoCieGLKmoWp02ln//g0dNERNk5jK3Byo2iKv1K7AEf9HddAT5UZdfcTz F+rVHcFv9/D/Kvyu0S9NJvMQG6SoUGHjr+xr1ZRN88t/z3FQ2MyLwZ0X037/BtxT6QlH TVb7v889jDcxYMYlGhiMVcN/i3kh4SYhYCLblR5ieOfNVF0U41MqgIqIQFsStbn2O6da yKef8kl5Jc41p2nr/OJXlw3bWXR+SEcOmuQcg5D3Icji/qOCqZd0M6/l2Gx/xkCfIMHf wibxUehIWFVTkx0Ybc0Er12Lh6aT/7SBQ/+7RrFqWwdT2fK7GYjZwHnUAFgMm58+JyuI ukOw== 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=GVygkQjjID+OmR+ja6uIzpBhMCRTyyoj3mLawY1JK1s=; b=Kv9uHkeqzdqAjlkR8zw53Y4raqcqUjH5WsnCqBKFieKJeuV4ZQAwoWjgkjijwbIgB3 fsMCNWmyGgI4igzc/tb4aNB5AOru/ryLl//7vLiDFGvCiao3/W5FN97rqLB3500phi36 PCnbsuljd3upLbith8dvYDEgsmLMwUAeXQ+QaWFz9KcQN9HBTfMWW9v1Lh546vqTmVRJ Dt8NQONZUmImIqxvzEnU+fiy90KZqk6ffBNH4GrZ3OPBDvfHoIa4qQ/wOG17ZJmWgHSv 8RvKZ1gr+Zr2bgNWL/MuAupAy9rPkPBj3hmOOk+l3NhK6NyH+iPR26T4KObef1PkU5XW J5Ug== X-Gm-Message-State: AGi0PuZ3Oc9nDYkb6zEGku+hRvBZH0gfCiJ+TqC5K2DHVlRtIeFnuU42 2ZQfpaxhkz1/nXU32Op4+HZBDfFPB0KnVg== X-Google-Smtp-Source: APiQypJX1oX934xj64aT+M765lxVv4oNNxnC3GEAU0mjJCD7jtJR7EnEq1JKRcrIJxMbwMzO+0Lidg== X-Received: by 2002:a17:90a:d17:: with SMTP id t23mr15040pja.77.1588118316804; Tue, 28 Apr 2020 16:58:36 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:58:20 -0700 Message-Id: <20200428235827.15383-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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..258a16ff2498 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(__rte_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