From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37971A0C4B; Sat, 13 Nov 2021 04:32:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81E5A410FA; Sat, 13 Nov 2021 04:32:18 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 4E91B4013F for ; Sat, 13 Nov 2021 04:32:15 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id q17so9896135plr.11 for ; Fri, 12 Nov 2021 19:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=rtNv5h39EY5Vipc1Orh/hXTibWunmLa++s7IQGadPePHLWtFvyuhfv2mb+adihTz2+ R1cUMuID4fUT5d2Sm/3LE7deM9gsHPZiG+vW3mWGhsHGXlPmpD13M24r+kFaor3ko361 ilbiYak/TnlkZRGjCKJx+rtZPodj6n5q40447/s2hGxx/h7X364CcSeTP5f6uWabLoMr GAk332bfYXRW2t8AbseyKXkJqLUMzWPt1ScPChBzlmayAK9qq1ZvVGsA+hvdagqsNbXi 3GNZdKtLlVZabrRh39Q5sxGDDXEiModE7WxaEIG5IfVq9p+OmrRQo2HUoM09xdLtzgwl RhUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=qnyBandkpwCiEstwMrmJdl5BEzuatIqihJmTRIU8U4/OZiJ/6v9rNYK3aa2HIT8ps+ V5HSDUJhbM9gF7F6Kc/ysoMFkDQxHgj6ijdXPwWxxqjHtkzSKz8kfM/eQNhrCniMPR6T 4+pMita+CJzWAmiRNuspZ4xoe+pDRV9YQXMiYeoo2d5xsaSybMWJpLo9rDOnCnQWYp2k /rhAAP00r/LtVsMC+duOIvSof+OO784A3k5j/it2VB4ODT/UWSeclFGgsfjI/AMfO799 L4YMVdlh1auYNFIULb+u5iG0FpOT/9X4FUOxUQ1A31Q+nRmKvtBXeE6B+VE1zYpJfHDH qN4w== X-Gm-Message-State: AOAM531x2QNTJCPKrHVrJFa3NDBLtKH89CFr/mxdNc/Pgx+7edN/OS0Q J7JdKJroPlxisA5LXlcCexMC8Ug56jxSXQ== X-Google-Smtp-Source: ABdhPJxCWlTW5OP5bKl2+sJwtgP9cxtOF3TkU4+467R4y3qMS5Ndj+kOGU19bLVzQ8x9mdrsmWwRoQ== X-Received: by 2002:a17:903:120c:b0:13f:d043:3477 with SMTP id l12-20020a170903120c00b0013fd0433477mr13774667plh.89.1636774333925; Fri, 12 Nov 2021 19:32:13 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id b9sm5999596pgf.15.2021.11.12.19.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 19:32:13 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v5 1/5] eal: close log in eal_cleanup Date: Fri, 12 Nov 2021 19:32:05 -0800 Message-Id: <20211113033209.341027-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113033209.341027-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113033209.341027-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When application calls rte_eal_cleanup on shutdown, the DPDK log should be closed and cleaned up. This helps reduce false reports from tools like ASAN and valgrind that track memory leaks. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 13 +++++++++++++ lib/eal/common/eal_private.h | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_log.c | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 1be35f539727..cbd0b851f216 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -18,6 +18,7 @@ #include #include "eal_log.h" +#include "eal_private.h" struct rte_log_dynamic_type { const char *name; @@ -535,3 +536,15 @@ eal_log_set_default(FILE *default_log) "Debug dataplane logs available - lower performance\n"); #endif } + +/* + * Called by eal_cleanup + */ +void +rte_eal_log_cleanup(void) +{ + if (default_log_stream) { + fclose(default_log_stream); + default_log_stream = NULL; + } +} diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 36bcc0b5a492..2fbad534b938 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void); */ int rte_eal_intr_init(void); +/** + * Close the default log stream + * + * This function is private to EAL. + */ +void rte_eal_log_cleanup(void); + /** * Init alarm mechanism. This is to allow a callback be called after * specific time. diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..b67030b2792e 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(internal_conf); + rte_eal_log_cleanup(); return 0; } diff --git a/lib/eal/linux/eal_log.c b/lib/eal/linux/eal_log.c index c0aa1007c4df..5a795ac9ebe3 100644 --- a/lib/eal/linux/eal_log.c +++ b/lib/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, }; /* -- 2.30.2