From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 809068E6F for ; Sat, 12 Dec 2015 09:12:12 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 12 Dec 2015 00:12:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,417,1444719600"; d="scan'208";a="872133749" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 12 Dec 2015 00:12:10 -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 tBC8CA6i011110; Sat, 12 Dec 2015 08:12:10 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id tBC8CAgO028411; Sat, 12 Dec 2015 08:12:10 GMT Received: (from ibetts@localhost) by sivswdev01.ir.intel.com with id tBC8CAWL028406; Sat, 12 Dec 2015 08:12:10 GMT From: Ian Betts To: dev@dpdk.org Date: Sat, 12 Dec 2015 08:12:08 +0000 Message-Id: <1449907928-28374-1-git-send-email-ian.betts@intel.com> X-Mailer: git-send-email 1.7.4.1 Cc: Ian Betts Subject: [dpdk-dev] [PATCH] examples/performance-thread: fix - cleanup before exit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Dec 2015 08:12:12 -0000 Fixes: 433ba6228f9a77a9b5f4 ("add pthread_shim app") The patch fixes an inverted return value in the cond_destroy and cond_init APIs of the pthread shim example. These APIs are now demonstrated in the sample app by having the mutexes and condition variables explicitly destroyed before the appplication terminates. Signed-off-by: Ian Betts --- examples/performance-thread/pthread_shim/main.c | 4 ++++ examples/performance-thread/pthread_shim/pthread_shim.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/performance-thread/pthread_shim/main.c b/examples/performance-thread/pthread_shim/main.c index 2f67c1b..dab379a 100644 --- a/examples/performance-thread/pthread_shim/main.c +++ b/examples/performance-thread/pthread_shim/main.c @@ -211,6 +211,10 @@ static void initial_lthread(void *args __attribute__((unused))) printf("error on thread exit\n"); } + pthread_cond_destroy(&exit_cond); + pthread_mutex_destroy(&print_lock); + pthread_mutex_destroy(&exit_lock); + /* shutdown the lthread scheduler */ lthread_scheduler_shutdown(rte_lcore_id()); lthread_detach(); diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c index 30cd68a..eda9d55 100644 --- a/examples/performance-thread/pthread_shim/pthread_shim.c +++ b/examples/performance-thread/pthread_shim/pthread_shim.c @@ -327,17 +327,24 @@ int pthread_cond_broadcast(pthread_cond_t *cond) return _sys_pthread_funcs.f_pthread_cond_broadcast(cond); } +int pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + if (override) + return lthread_mutex_destroy(*(struct lthread_mutex **)mutex); + return _sys_pthread_funcs.f_pthread_mutex_destroy(mutex); +} + int pthread_cond_destroy(pthread_cond_t *cond) { if (override) - return -lthread_cond_destroy(*(struct lthread_cond **)cond); + return lthread_cond_destroy(*(struct lthread_cond **)cond); return _sys_pthread_funcs.f_pthread_cond_destroy(cond); } int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { if (override) - return -lthread_cond_init(NULL, + return lthread_cond_init(NULL, (struct lthread_cond **)cond, (const struct lthread_condattr *) attr); return _sys_pthread_funcs.f_pthread_cond_init(cond, attr); -- 2.1.4