From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatoly Burakov Subject: [PATCH v4 5/5] eal: simplify IPC sync request timeout code Date: Fri, 2 Mar 2018 15:14:12 +0000 Message-ID: <819b8a333e8ec5f3b99f94c875e7e13a7c761f2b.1520000413.git.anatoly.burakov@intel.com> References: Cc: jianfeng.tan@intel.com, keith.wiles@intel.com To: dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 539B25B3E for ; Fri, 2 Mar 2018 16:14:19 +0100 (CET) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Anatoly Burakov --- 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