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 00EB9A00BE; Wed, 29 Apr 2020 01:58:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4A7A1D66E; Wed, 29 Apr 2020 01:58:42 +0200 (CEST) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id B10211D661 for ; Wed, 29 Apr 2020 01:58:39 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id 7so1652694pjo.0 for ; Tue, 28 Apr 2020 16:58:39 -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=7qwyrh0lTMXNcai1naQp777bSa6cojehYV6tpKV4jWQ=; b=IvgzDNs1ANDH7WLR7UFX/3VzAzAfDhwXIX7MedVjk1eCj1/u1A11Sw6AiGhiwloqds myE4wlsNY42EXQFpEq7RMIedfvicNI03Dy6rEQko8rBIoS1ag7TIi5RKu4/k9JYTJ72w bTfXPxvvrRH7/2mpIol8/HfmIFqbMjRHtdlu7DyLkfl3aHUKIH7pK2OGEoUWkwljXDnn ecp8xOOD1pmLZOq19O+7Rjym/75hM8CWSzgcEECuOLIwzgE290wQRe8zH5m0leJDFHVG Nj/WCIcBMLC89hFPUUEE198SnG471imD4kWzOIw0EONmd8GqStlU9h8vMI0INyWP5ISs 2Vsw== 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=7qwyrh0lTMXNcai1naQp777bSa6cojehYV6tpKV4jWQ=; b=nuWzu7mY9Qv5EZ+DqaAHscSYuOUaMJfOu9t9xEBHrM6EM4PDbrYzyoFtay8zb68NZc X0Ey7J3sTIfPudG4eslfM/FU1zWVwJjN2Q+2jJYqKvwpZ62WfsCtWo4r+WVnjcDmY7QD EbVtz26GSBovgMl1XyWpOpWhgw0CxT/drblCIA3tzjU8SXHunsD7xxLbNLGg96KUEZ7j h13/KmdlKtbYMQqdr/O+itKc31Vt9eqvUvSnOOfG3J0mvk8C2vWBHKdVXkQivMexCalg TuIocGnuQ6JDhOOBpSGrmJfJKMMShQX0Cl1xeAGoy4dddovQEgHAppB2nfmm80DvxZY3 zNRw== X-Gm-Message-State: AGi0PuZjo6RWiKxsbCccHU1+4HIj7ktf4shofYFNPJnJ6YA+eQOdxIbw nTl3buvKVvKS+JBrrErEQtgXp/5Dk1uLLg== X-Google-Smtp-Source: APiQypJC4iUFLfubX9C7ujxH95yvLKsflkb2NMBpgbkmVUc3P9KmMje4Z2YY01ozC+JDhO8Si7ae9g== X-Received: by 2002:a17:90a:1b4c:: with SMTP id q70mr18767pjq.55.1588118318370; Tue, 28 Apr 2020 16:58:38 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:37 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 28 Apr 2020 16:58:21 -0700 Message-Id: <20200428235827.15383-3-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 2/8] 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 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 43de798ae96a..a37cd86f7743 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; }; @@ -486,8 +487,26 @@ 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) { + if (opt_ll->pattern != NULL) + free(opt_ll->pattern); + else + regfree(&opt_ll->re_match); + 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