From mboxrd@z Thu Jan 1 00:00:00 1970 From: "E. Scott Daniels" Subject: [PATCH] net/ixgbe: prevent duplicate callback on list Date: Wed, 19 Oct 2016 18:23:07 -0400 Message-ID: <1476915787-28205-2-git-send-email-daniels@research.att.com> References: <1476915787-28205-1-git-send-email-daniels@research.att.com> Cc: dev@dpdk.org, az5157@att.com, "E. Scott Daniels" To: helin.zhang@intel.com, bernard.iremonger@intel.com Return-path: Received: from mx0a-00191d01.pphosted.com (mx0a-00191d01.pphosted.com [67.231.149.140]) by dpdk.org (Postfix) with ESMTP id 7CDFE6CD1 for ; Thu, 20 Oct 2016 00:23:35 +0200 (CEST) In-Reply-To: <1476915787-28205-1-git-send-email-daniels@research.att.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This change prevents the attempt to add a structure which is already on the callback list. If a struct with matching parameters is found on the list, then no action is taken. If a struct with matching parameters is found on the list, then no action is taken. Signed-off-by: E. Scott Daniels --- lib/librte_ether/rte_ethdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0d9d9c1..fde8112 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2449,14 +2449,15 @@ rte_eth_dev_callback_register(uint8_t port_id, } /* create a new callback. */ - if (user_cb == NULL) + if (user_cb == NULL) { user_cb = rte_zmalloc("INTR_USER_CALLBACK", sizeof(struct rte_eth_dev_callback), 0); - if (user_cb != NULL) { - user_cb->cb_fn = cb_fn; - user_cb->cb_arg = cb_arg; - user_cb->event = event; - TAILQ_INSERT_TAIL(&(dev->link_intr_cbs), user_cb, next); + if (user_cb != NULL) { + user_cb->cb_fn = cb_fn; + user_cb->cb_arg = cb_arg; + user_cb->event = event; + TAILQ_INSERT_TAIL(&(dev->link_intr_cbs), user_cb, next); + } } rte_spinlock_unlock(&rte_eth_dev_cb_lock); -- 1.9.1