examples/performance-thread: fix return sign
authorIan Betts <ian.betts@intel.com>
Sat, 12 Dec 2015 08:12:08 +0000 (08:12 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sat, 12 Dec 2015 21:32:59 +0000 (22:32 +0100)
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.

Fixes: 433ba6228f9a77a9b5f4 ("add pthread_shim app")

Signed-off-by: Ian Betts <ian.betts@intel.com>
examples/performance-thread/pthread_shim/main.c
examples/performance-thread/pthread_shim/pthread_shim.c

index 2f67c1b..dab379a 100644 (file)
@@ -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();
index 30cd68a..0fd36ba 100644 (file)
@@ -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);