DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ian Betts <ian.betts@intel.com>
To: dev@dpdk.org
Cc: Ian Betts <ian.betts@intel.com>
Subject: [dpdk-dev] [PATCH] examples/performance-thread: fix - cleanup before exit
Date: Sat, 12 Dec 2015 08:12:08 +0000	[thread overview]
Message-ID: <1449907928-28374-1-git-send-email-ian.betts@intel.com> (raw)

 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 <ian.betts@intel.com>
---
 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

             reply	other threads:[~2015-12-12  8:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-12  8:12 Ian Betts [this message]
2015-12-12 20:52 ` 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=1449907928-28374-1-git-send-email-ian.betts@intel.com \
    --to=ian.betts@intel.com \
    --cc=dev@dpdk.org \
    /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).