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 D3621A00BE; Wed, 29 Apr 2020 01:14:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ECDF31D645; Wed, 29 Apr 2020 01:14:32 +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 CB7B41D63C for ; Wed, 29 Apr 2020 01:14:28 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id hi11so172527pjb.3 for ; Tue, 28 Apr 2020 16:14:28 -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=IvPx+P1BNuUg3uTojmrfsF4XzRPGx/aM68i0zaXmb4bFoF8a8w8YryRMgDg5zUN/uV KxJ7I3vI+bI9sm31U2DE9/wjedVsQmsHSIVInFpNwylu0IJ8dJQCShgNcOWbcJkAMVBv poKrTAoWIWdhVDJfpzuzp+2CTlJ1qxwt0ciMQrEvVGUMKX9xlqe8SDpveuR7qdpK87jU BlWKArJDJOLtF9B8s4brKc7BME9MUfQVtTt433n/6u/e4AnpCTiRWLCHeNJ9kCPAlSnd NA5VocuEn5LF4v4POZVVYDOFu9ZacaPb6gn/ajZC/ddIDEpliTO6fB0iIxQlAzJbdOzT zf2A== 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=KhmjY+yR1eeLD49XnZanlCKOly31/xvhZ8FpUNGZmfybpWipT1I+9kB5YG3CWtMb2S Uz3UYDQQQXYyAg4yK3s1tUCim/0ZW1AEBuKtZ3j0ALwi4zsCVY4/FdPu/vXcsz18CsyS 9RhPndVdWbKP0AiMfVH4fXDL82OWzo4Jk1/aH6bA+A9FmwARLV9/allTq8aO03Eh0Yp1 RH0jhTuaDyMKWtyguQ0IJhPDj0Yx5Z49cK/bhd1Q014VMX4tzec9/gA0pScA6iH0Nepj qWUJj1wC1uYfxQksMdv5SPUWAeA94XLQhULbgJSaMIMijAX91yPETz5vXNY5evtc0cTb 0qAw== X-Gm-Message-State: AGi0Pua3/giHXZDxeX6HLO6If8LLx5gyoESDOBGk4aQM2pjJBbqIYxYW Xm1XqREdEkLAGaFL2Uwhi4wDCfpJszYGJA== X-Google-Smtp-Source: APiQypJoL0BmDPk6W0ByAx+I+5Avyx7RuwGS3rKgA+EMRHh0NRfpHOI4mbWmg8k7s3VqbCZv9348pA== X-Received: by 2002:a17:90a:3f8e:: with SMTP id m14mr7306927pjc.92.1588115667348; Tue, 28 Apr 2020 16:14:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 28 Apr 2020 16:14:09 -0700 Message-Id: <20200428231415.17985-3-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 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