From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A0B72A04DD;
	Sat,  4 Jan 2020 02:34:02 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F38031D515;
	Sat,  4 Jan 2020 02:33:53 +0100 (CET)
Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com
 [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id 820A11D501
 for <dev@dpdk.org>; Sat,  4 Jan 2020 02:33:51 +0100 (CET)
Received: by mail-pj1-f67.google.com with SMTP id kx11so5205449pjb.4
 for <dev@dpdk.org>; Fri, 03 Jan 2020 17:33:51 -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=Q1ASW5G4GyNaqPRmx2JfkXHsJxMS+tbeKnlEF3gNxPw=;
 b=U1/AXaHLius3ILKn4DgrhlLInsyN1ntcQ3ilgwo9QCZg6znx1NZXreCPqCqyBaPQOP
 s/dX+VO4i3Lhb2LY4dHBLrRIS9skkQpcj/1tEsGyDGE6OuHXBK58f5CdYxOLi6mjD+FN
 oqMtaLUPG0BTIvgUqxWb86pvDjpZjQYJn8Rzv4IlvwjpW9aUlyNdm0upHvWnsgsp15HV
 WWZ107Ur5jiaOR7CoC6OeWBjzk4GRNFdo9MKdrbXl0iLnguHahPghNj/unJtTu/6uMa0
 M6VcQ7EtXgon/sdTkhMvZPQ1afeoH5PF8+dkRO1J2tGqWtMfCLhdwX08FOWSxjTllw2f
 FPIA==
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=Q1ASW5G4GyNaqPRmx2JfkXHsJxMS+tbeKnlEF3gNxPw=;
 b=rJIVyyRBdWt0FoGaVGF2Cpl3weXsVdLn5WHGjrFUrC1rwRInCskfD0M3frExkh7xUv
 5MOnIhidoyqPma/sHsTtcnAeEzM0i9beCTLGYWxRyjWJCBrs8ntyfPP54AeWpfHy3RHC
 fDofZYAlb2brAIT4GkpIPiVa9vn8LkUXF+a40qc3RU/5u7DlgJrmr+fwifPVTfR6RF2+
 +WyDYYzVhgoAB63ejz8p/M3ERUGI1BKK82/qkK5WuzgCXXZmeWGkPzthlvLyc3NHJ2T6
 7c8MTyDy+2cnfASelw5CEdJqUlpXhZbfR3TJ7iSBVepjZqR3JPYmOJ6qaL3rt25FtFY6
 fe0A==
X-Gm-Message-State: APjAAAUnLpU8KL1RhFGGlr9gms2UNFMMLavxodTxFj0VZSXzfZDJvFcu
 9I3KepiDDJevf1r9kPTPT/FJI8DrMiA=
X-Google-Smtp-Source: APXvYqxI+jjti10YNdtycxEBvt3ZV+DaWzExoTXXOtezARveLUosThWaJZXX8QNE18wGMYnvgFz7kQ==
X-Received: by 2002:a17:90a:c697:: with SMTP id
 n23mr29277840pjt.37.1578101630298; 
 Fri, 03 Jan 2020 17:33:50 -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.49
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 03 Jan 2020 17:33:49 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Date: Fri,  3 Jan 2020 17:33:28 -0800
Message-Id: <20200104013341.19809-2-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 01/14] eal: log: close on cleanup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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 <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_common_log.c | 12 ++++++++++++
 lib/librte_eal/common/eal_private.h    | 13 +++++++++++++
 lib/librte_eal/linux/eal/eal.c         |  1 +
 lib/librte_eal/linux/eal/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 c0efd5214fa9..64d6e20947ed 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -463,3 +463,15 @@ eal_log_set_default(FILE *default_log)
 		"Debug dataplane logs available - lower performance\n");
 #endif
 }
+
+/*
+ * Called by envrionment-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 8a9d493f0c54..fdd942d71a36 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -90,6 +90,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
  *
@@ -151,6 +157,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/eal.c b/lib/librte_eal/linux/eal/eal.c
index c4233ec3c8ac..a3381fd01a23 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -1327,6 +1327,7 @@ rte_eal_cleanup(void)
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
 	eal_cleanup_config(&internal_config);
+	rte_eal_log_cleanup();
 	return 0;
 }
 
diff --git a/lib/librte_eal/linux/eal/eal_log.c b/lib/librte_eal/linux/eal/eal_log.c
index 9d02dddbed33..e1adbc91637a 100644
--- a/lib/librte_eal/linux/eal/eal_log.c
+++ b/lib/librte_eal/linux/eal/eal_log.c
@@ -37,8 +37,16 @@ console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)
 	return ret;
 }
 
+static int
+console_log_close(__attribute__((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