The macro definitions of the following pthread functions
return incorrect values from the inner function return code.
While pthread_barrier_init(), pthread_barrier_destroy() and
pthread_cancel() return 0 in a case of success and non-zero (errno) value
otherwise the shimming functions InitializeSynchronizationBarrier,
DeleteSynchronizationBarrier and TerminateThread return FALSE (0)
in a case of failure and TRUE(1) in a case of success.
This issue was undetected as none of the functions return codes were
checked until such check was added in
commit
34cc55cce6b1 ("eal: fix race in control thread creation")
exposing the issue by failing pthread_barrier_init()
and rte_eal_init() on Windows as a result.
The fix aligned the return value of the 3 function with the expected
pthread API return values.
Fixes:
e8428a9d89f1 ("eal/windows: add some basic functions and macros")
Cc: stable@dpdk.org
Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
static void ctrl_params_free(struct rte_thread_ctrl_params *params)
{
if (__atomic_sub_fetch(¶ms->refcnt, 1, __ATOMIC_ACQ_REL) == 0) {
- pthread_barrier_destroy(¶ms->configured);
+ (void)pthread_barrier_destroy(¶ms->configured);
free(params);
}
}
return -ret;
fail_with_barrier:
- pthread_barrier_destroy(¶ms->configured);
+ (void)pthread_barrier_destroy(¶ms->configured);
fail_no_barrier:
free(params);
typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
#define pthread_barrier_init(barrier, attr, count) \
- InitializeSynchronizationBarrier(barrier, count, -1)
+ !InitializeSynchronizationBarrier(barrier, count, -1)
#define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
#define pthread_barrier_destroy(barrier) \
- DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) TerminateThread((HANDLE) thread, 0)
+ !DeleteSynchronizationBarrier(barrier)
+#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
/* pthread function overrides */
#define pthread_self() \