From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 58C3A5F12 for ; Fri, 2 Mar 2018 09:41:40 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 00:41:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,411,1515484800"; d="scan'208";a="21999980" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga008.jf.intel.com with ESMTP; 02 Mar 2018 00:41:38 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w228fboR009988; Fri, 2 Mar 2018 08:41:37 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w228fb3W028745; Fri, 2 Mar 2018 08:41:37 GMT Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w228fbiT028741; Fri, 2 Mar 2018 08:41:37 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: jianfeng.tan@intel.com Date: Fri, 2 Mar 2018 08:41:37 +0000 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <2c7afdce0160171947afa94fb29ac97f619b2f87.1519940460.git.anatoly.burakov@intel.com> References: <2c7afdce0160171947afa94fb29ac97f619b2f87.1519940460.git.anatoly.burakov@intel.com> In-Reply-To: <53373b6d98cc54581eff8fecd277ebca077e589e.1519311106.git.anatoly.burakov@intel.com> References: <53373b6d98cc54581eff8fecd277ebca077e589e.1519311106.git.anatoly.burakov@intel.com> Subject: [dpdk-dev] [PATCH v2 5/5] eal: fix race condition in IPC requests 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: , X-List-Received-Date: Fri, 02 Mar 2018 08:41:40 -0000 Unlocking the action list before sending message and locking it again aftterwards introduces a window where a response might arrive before we have a chance to start waiting on a condition, resulting in timeouts on valid messages. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Cc: jianfeng.tan@intel.com Signed-off-by: Anatoly Burakov --- Notes: v2: added this patch lib/librte_eal/common/eal_common_proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 3a1088e..da7930f 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -561,10 +561,10 @@ mp_request_one(const char *dst, struct rte_mp_msg *req, exist = find_sync_request(dst, req->name); if (!exist) TAILQ_INSERT_TAIL(&sync_requests.requests, &sync_req, next); - pthread_mutex_unlock(&sync_requests.lock); if (exist) { RTE_LOG(ERR, EAL, "A pending request %s:%s\n", dst, req->name); rte_errno = EEXIST; + pthread_mutex_unlock(&sync_requests.lock); return -1; } @@ -578,7 +578,6 @@ mp_request_one(const char *dst, struct rte_mp_msg *req, reply->nb_sent++; - pthread_mutex_lock(&sync_requests.lock); do { pthread_cond_timedwait(&sync_req.cond, &sync_requests.lock, ts); /* Check spurious wakeups */ -- 2.7.4