From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <aburakov@ecsmtp.ir.intel.com>
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by dpdk.org (Postfix) with ESMTP id 539B25B3E
 for <dev@dpdk.org>; Fri,  2 Mar 2018 16:14:19 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga007.fm.intel.com ([10.253.24.52])
 by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 02 Mar 2018 07:14:15 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="21412698"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by fmsmga007.fm.intel.com with ESMTP; 02 Mar 2018 07:14:13 -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
 w22FEDA1001239; Fri, 2 Mar 2018 15:14:13 GMT
Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1])
 by sivswdev01.ir.intel.com with ESMTP id w22FEDUh032147;
 Fri, 2 Mar 2018 15:14:13 GMT
Received: (from aburakov@localhost)
 by sivswdev01.ir.intel.com with LOCAL id w22FEDkR032143;
 Fri, 2 Mar 2018 15:14:13 GMT
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: jianfeng.tan@intel.com, keith.wiles@intel.com
Date: Fri,  2 Mar 2018 15:14:12 +0000
Message-Id: <819b8a333e8ec5f3b99f94c875e7e13a7c761f2b.1520000413.git.anatoly.burakov@intel.com>
X-Mailer: git-send-email 1.7.0.7
In-Reply-To: <a9cae982af2307c7fa59406723bca84004de5ff6.1520000413.git.anatoly.burakov@intel.com>
References: <a9cae982af2307c7fa59406723bca84004de5ff6.1520000413.git.anatoly.burakov@intel.com>
In-Reply-To: <df64cdb071cef1002de60c963701a49e1bc3f155.1519322682.git.anatoly.burakov@intel.com>
References: <df64cdb071cef1002de60c963701a49e1bc3f155.1519322682.git.anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH v4 5/5] eal: simplify IPC sync request timeout
	code
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://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 02 Mar 2018 15:14:19 -0000

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_proc.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index f382184..666c566 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -706,7 +706,6 @@ mp_request_one(const char *dst, struct rte_mp_msg *req,
 	       struct rte_mp_reply *reply, const struct timespec *ts)
 {
 	int ret;
-	struct timeval now;
 	struct rte_mp_msg msg, *tmp;
 	struct sync_request sync_req, *exist;
 
@@ -738,19 +737,10 @@ mp_request_one(const char *dst, struct rte_mp_msg *req,
 	reply->nb_sent++;
 
 	do {
-		pthread_cond_timedwait(&sync_req.cond, &sync_requests.lock, ts);
-		/* Check spurious wakeups */
-		if (sync_req.reply_received == 1)
-			break;
-		/* Check if time is out */
-		if (gettimeofday(&now, NULL) < 0)
-			break;
-		if (ts->tv_sec < now.tv_sec)
-			break;
-		else if (now.tv_sec == ts->tv_sec &&
-			 now.tv_usec * 1000 < ts->tv_nsec)
-			break;
-	} while (1);
+		ret = pthread_cond_timedwait(&sync_req.cond,
+				&sync_requests.lock, ts);
+	} while (ret != 0 && ret != ETIMEDOUT);
+
 	/* We got the lock now */
 	TAILQ_REMOVE(&sync_requests.requests, &sync_req, next);
 	pthread_mutex_unlock(&sync_requests.lock);
-- 
2.7.4