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 E8AA8A04DD; Sat, 4 Jan 2020 02:34:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B50CE1D523; Sat, 4 Jan 2020 02:33:55 +0100 (CET) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id E361C1D50F for ; Sat, 4 Jan 2020 02:33:52 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id j11so5213857pjs.1 for ; Fri, 03 Jan 2020 17:33:52 -0800 (PST) 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=3V/PyXSkQ6Kas8dlVEV3BLmfn15GIMCv9VsMg2bfyJs=; b=jz5IbWjMd1rD9zr02sHJQLIyFp33F2XJtuZjMXzZwKH0+gC4dI+NOCaft+zRS5TxjB HIiE+DXIF7Gcwvi1eGViG6RNWnLAraGk99oJBLfixG382Szo4eXrNVtxZmW8mKigWwrI tD/OBG3FMI3+2NtVed2eab7DdEYEtCvKcuz2HTfvV6n5Hv+H7WonXipIXXFMATZsHNC7 g+jOYuCnwRVWBeHRifg+kQTDi4rFxvOWYiDPrSQejTQQKI2s0+wEZfUSGAxmX40LxGgU QEpxFsWelwrEEw/RP7ULb0VTnMg389u0mBsfEtAO+5np6KOyeDrsz+RW7IYQ1oy81B3Y NtoA== 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=3V/PyXSkQ6Kas8dlVEV3BLmfn15GIMCv9VsMg2bfyJs=; b=tgA7+W1n4fnlZWozChnHedrej1XiAIu9B18Tx+f/vfSNnYQXoduVNgyBoR8kvA8cSm 4uLhShNAqzAD1fKnhx7nVI3GGP+cpFCxbPlXlzWc1agjdnKuG2PnHQeMBPe5K1DOLbbQ pn1U3yQ6QPvEAyfeyBvYdmBOxU1U67AkGGYNGV5JvCw+fmgSHaWI4by+2Lh+PfES3G/X HZGIJgkCVA5nacKJHkGfO+Xt812OvUofLq8iDTxlvJqpKpAkRSzgWaT/+6rXic1GSou/ 4ZvlODFPOQGf2gjs3chmryT1cYijeoANskFX/MqP+hj8fSLXqS8x0pSyWoyH0m75mYAX oMZw== X-Gm-Message-State: APjAAAW2Rd7GxPuQ6yEXjyJ4lDZtC5gd0TLT/N+aydC79CynC2q5WDqo 0TdZpxH1mQ4hcek3PrgKbhBAUy7phW0= X-Google-Smtp-Source: APXvYqz/4B6dcrEOjTP4J5LL4FRSpoiPvjfsDXFhvltcAMdU/J+jVdSMyIPRn1tKW3CIid8ZcFicpw== X-Received: by 2002:a17:902:ff07:: with SMTP id f7mr52011920plj.12.1578101631658; Fri, 03 Jan 2020 17:33:51 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j6sm16212934pjv.10.2020.01.03.17.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 17:33:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Fri, 3 Jan 2020 17:33:29 -0800 Message-Id: <20200104013341.19809-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200104013341.19809-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 02/14] eal: log: free dynamic state 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 rte_eal_cleanup is called, free all the memory associated with dynamic log levels and types. Fixes: c1b5fa94a46f ("eal: support dynamic log types") Cc: olivier.matz@6wind.com Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/eal_common_log.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 64d6e20947ed..7583bdc57619 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "eal_private.h" @@ -54,7 +55,7 @@ struct log_cur_msg { }; struct rte_log_dynamic_type { - const char *name; + char *name; uint32_t loglevel; }; @@ -470,8 +471,23 @@ eal_log_set_default(FILE *default_log) void eal_log_cleanup(void) { + struct rte_eal_opt_loglevel *opt_ll, *tmp; + size_t i; + if (default_log_stream) { fclose(default_log_stream); default_log_stream = NULL; } + + TAILQ_FOREACH_SAFE(opt_ll, &opt_loglevel_list, next, tmp) { + free(opt_ll->pattern); + free(opt_ll); + } + + for (i = 0; i < rte_logs.dynamic_types_len; i++) + free(rte_logs.dynamic_types[i].name); + + rte_logs.dynamic_types_len = 0; + free(rte_logs.dynamic_types); + rte_logs.dynamic_types = NULL; } -- 2.20.1