Skip to content

Commit 9ce2ccc

Browse files
committed
ompi request handling race condition fix (MT-case)
Described in #1813
1 parent dac9201 commit 9ce2ccc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

opal/threads/wait_sync.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* reserved.
66
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
77
* reserved.
8+
* Copyright (c) 2016 Mellanox Technologies. All rights reserved.
89
* $COPYRIGHT$
910
*
1011
* Additional copyrights may follow
@@ -33,15 +34,16 @@ typedef struct ompi_wait_sync_t {
3334

3435
#define WAIT_SYNC_RELEASE(sync) \
3536
if (opal_using_threads()) { \
37+
while( (sync)->count >= 0 ); \
3638
pthread_cond_destroy(&(sync)->condition); \
3739
pthread_mutex_destroy(&(sync)->lock); \
3840
}
3941

4042
#define WAIT_SYNC_SIGNAL(sync) \
4143
if (opal_using_threads()) { \
42-
pthread_mutex_lock(&(sync->lock)); \
43-
pthread_cond_signal(&sync->condition); \
44-
pthread_mutex_unlock(&(sync->lock)); \
44+
pthread_cond_signal(&(sync)->condition); \
45+
/* pthread_cond_signal assumes wmb() */ \
46+
sync->count = -1; \
4547
}
4648

4749
OPAL_DECLSPEC int sync_wait_mt(ompi_wait_sync_t *sync);

0 commit comments

Comments
 (0)