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 3B3C2A04DD;
	Sat,  4 Jan 2020 02:34:39 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 881091D522;
	Sat,  4 Jan 2020 02:34:01 +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 EB2CB1D527
 for <dev@dpdk.org>; Sat,  4 Jan 2020 02:33:56 +0100 (CET)
Received: by mail-pj1-f68.google.com with SMTP id bg7so5353288pjb.5
 for <dev@dpdk.org>; Fri, 03 Jan 2020 17:33:56 -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=xxeb7t92o0tojQKq8wkvvjXExuQ6Ub6YujsdRzIxFg4=;
 b=v1qMLsBhDhC37cSK+qTrMVjrJglb9YyQUKwBoE+2VM3XdLPDipB8JwftwK1B9CxVaG
 8eDLCTh9lpVDvK/2itTwPBvBcvNgXhXqtKtwzGwxdmSk0PjngbpRzl7rTkwsKgVHxWki
 Cds8g87Yn5IlE0VJX66YXNjVlTmt5Byz1ulp+bbQ65HO0SZfEBNNbxB/AA9DCWuEwnMm
 xiT03xzX6Nrbq3bRD4j0cJBPDa1EIYCifZvRgfgBFuNx1ABqjdpjMHYe9wv3nabhhvw+
 4I0u5PXal3GYuxIcvFmClDma8rMOp/eeWdWVASyQHNNX5FTKVdAfsvqRtyJN07dJHaG9
 kvQQ==
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=xxeb7t92o0tojQKq8wkvvjXExuQ6Ub6YujsdRzIxFg4=;
 b=p1SShmXfmnO8urV4v0S14ohpEDOZnZTMvI3uLKL10ZwyexhLQgsQ/i4Y+iM745RrOY
 6NBr7MSNozvIRX8dBAeyg6NmhcYQWlS/pn6MOqXDli3fTSM++10pNROIQzaTrrN/AovT
 kjAuwm+IP4FLdhztKisbHKJhKCJ44Z6k8e4QYiBKsTdsY/hwP16iHtmAPXk5UbpyORsn
 hj08Nruo+eSQe3HQHergPI7X/J0zSyqpEu8j1CE9ACH3ZEi46JeY5kmui2tjIIQ7Q9FX
 nds/96mm6ye0RFxrvTXAz/GkumRNFO1be+Y2rVq9gDWsHW1RSsLzlwYsWlvpHpcqxN1X
 Avkw==
X-Gm-Message-State: APjAAAXxKfutFuW4DF8WhTFz+6UiGo/wMZPPiBZj1Wj6kOdZDPs9kS5v
 uZAyWU7Rqez8qTKMM2ivK4AArvduSio=
X-Google-Smtp-Source: APXvYqxYB1V54HgGPSIOfnW0TdWNBowG3U6D093xpScwwXubv50DrfpdMLDlyBuJa/ET/Kqnt1Ht1g==
X-Received: by 2002:a17:902:b611:: with SMTP id
 b17mr95245830pls.210.1578101635544; 
 Fri, 03 Jan 2020 17:33:55 -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.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 03 Jan 2020 17:33:54 -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:32 -0800
Message-Id: <20200104013341.19809-6-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 05/14] eal: intr: cleanup resources
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 rte_eal_cleanup is called the interrupt thread and
associated resources should be cleaned up.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/eal_private.h       | 10 ++++++++++
 lib/librte_eal/linux/eal/eal.c            |  1 +
 lib/librte_eal/linux/eal/eal_interrupts.c |  9 +++++++++
 3 files changed, 20 insertions(+)

diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 38682e79827c..c62f35d3ac0f 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -191,6 +191,16 @@ int rte_eal_tailqs_init(void);
  */
 int rte_eal_intr_init(void);
 
+/**
+ * Cleanup interrupt handling.
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ *  0 on success, negative on error
+ */
+void rte_eal_intr_cleanup(void);
+
 /**
  * Init alarm mechanism. This is to allow a callback be called after
  * specific time.
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index d98a2afe85da..eb95f4f0c317 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -1338,6 +1338,7 @@ rte_eal_cleanup(void)
 	}
 
 	rte_service_finalize();
+	rte_eal_intr_cleanup();
 	rte_eal_alarm_cleanup();
 	rte_mp_channel_cleanup();
 	eal_cleanup_config(&internal_config);
diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c
index 14ebb108cee9..fa08ac4171bd 100644
--- a/lib/librte_eal/linux/eal/eal_interrupts.c
+++ b/lib/librte_eal/linux/eal/eal_interrupts.c
@@ -1137,6 +1137,15 @@ rte_eal_intr_init(void)
 	return ret;
 }
 
+void
+rte_eal_intr_cleanup(void)
+{
+	pthread_cancel(intr_thread);
+	pthread_join(intr_thread, NULL);
+	close(intr_pipe.readfd);
+	close(intr_pipe.writefd);
+}
+
 static void
 eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)
 {
-- 
2.20.1