-
Notifications
You must be signed in to change notification settings - Fork 9
Possible data races without locking #127
Copy link
Copy link
Closed
Description
Hi, it seems the lock_handle should be protected by locks?
pmix-tests/prrte/debug/test-utils.c
Line 33 in 765fa58
| static int lock_handle; |
pmix-tests/prrte/debug/test-utils.c
Lines 79 to 91 in 765fa58
| void lock_stream() { | |
| if (0 < lock_handle) { | |
| flock(lock_handle, LOCK_EX); | |
| } | |
| pthread_mutex_lock(&thread_lock); | |
| } | |
| void unlock_stream() { | |
| pthread_mutex_unlock(&thread_lock); | |
| if (0 < lock_handle) { | |
| flock(lock_handle, LOCK_UN); | |
| } | |
| } |
Just like this.
void lock_stream() {
pthread_mutex_lock(&thread_lock);
if (0 < lock_handle) {
flock(lock_handle, LOCK_EX);
}
}
void unlock_stream() {
if (0 < lock_handle) {
flock(lock_handle, LOCK_UN);
}
pthread_mutex_unlock(&thread_lock);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels