DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: jianfeng.tan@intel.com
Subject: [dpdk-dev] [PATCH v2 5/5] eal: fix race condition in IPC requests
Date: Fri,  2 Mar 2018 08:41:37 +0000	[thread overview]
Message-ID: <fe5de52fe7f6c9735cee140d3687904acf4fbe27.1519940460.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <2c7afdce0160171947afa94fb29ac97f619b2f87.1519940460.git.anatoly.burakov@intel.com>
In-Reply-To: <53373b6d98cc54581eff8fecd277ebca077e589e.1519311106.git.anatoly.burakov@intel.com>

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 <anatoly.burakov@intel.com>
---

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

  parent reply	other threads:[~2018-03-02  8:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 15:43 [dpdk-dev] [PATCH 1/4] eal: fix IPC timeouts Anatoly Burakov
2018-02-22 15:43 ` [dpdk-dev] [PATCH 2/4] eal: fix IPC socket paths Anatoly Burakov
2018-02-23  3:14   ` Tan, Jianfeng
2018-02-22 15:44 ` [dpdk-dev] [PATCH 3/4] eal: fix IPC request " Anatoly Burakov
2018-02-23  3:15   ` Tan, Jianfeng
2018-02-22 15:44 ` [dpdk-dev] [PATCH 4/4] eal: fix handling of errno values in IPC Anatoly Burakov
2018-02-23  3:16   ` Tan, Jianfeng
2018-02-23  3:11 ` [dpdk-dev] [PATCH 1/4] eal: fix IPC timeouts Tan, Jianfeng
2018-03-02  8:41 ` [dpdk-dev] [PATCH v2 1/5] " Anatoly Burakov
2018-03-02  8:41 ` [dpdk-dev] [PATCH v2 2/5] eal: fix IPC socket paths Anatoly Burakov
2018-03-02  8:41 ` [dpdk-dev] [PATCH v2 3/5] eal: fix IPC request " Anatoly Burakov
2018-03-02  8:41 ` [dpdk-dev] [PATCH v2 4/5] eal: fix handling of errno values in IPC Anatoly Burakov
2018-03-02  8:41 ` Anatoly Burakov [this message]
2018-03-07 14:06   ` [dpdk-dev] [PATCH v2 5/5] eal: fix race condition in IPC requests Tan, Jianfeng
2018-03-21  8:51     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe5de52fe7f6c9735cee140d3687904acf4fbe27.1519940460.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).