aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-06-01 11:22:22 +1200
committerThomas Munro <tmunro@postgresql.org>2021-06-01 11:31:06 +1200
commita40646e30d85e51a76fb620822d4d921b6802157 (patch)
treee2a1bfb5d543b519646be7e83dcb36152105c39a
parent7c544ecdad814ccda709cfb6aa7d62840c3a7486 (diff)
downloadpostgresql-a40646e30d85e51a76fb620822d4d921b6802157.tar.gz
postgresql-a40646e30d85e51a76fb620822d4d921b6802157.zip
Fix error handling in replacement pthread_barrier_init().
Commit 44bf3d50 incorrectly used an errno-style interface when supplying missing pthread functionality (i.e. on macOS), but it should check for and return error numbers directly.
-rw-r--r--src/port/pthread_barrier_wait.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/port/pthread_barrier_wait.c b/src/port/pthread_barrier_wait.c
index 7ca8e2ce0be..8282cc5b89d 100644
--- a/src/port/pthread_barrier_wait.c
+++ b/src/port/pthread_barrier_wait.c
@@ -18,19 +18,17 @@
int
pthread_barrier_init(pthread_barrier_t *barrier, const void *attr, int count)
{
+ int error;
+
barrier->sense = false;
barrier->count = count;
barrier->arrived = 0;
- if (pthread_cond_init(&barrier->cond, NULL) < 0)
- return -1;
- if (pthread_mutex_init(&barrier->mutex, NULL) < 0)
+ if ((error = pthread_cond_init(&barrier->cond, NULL)) != 0)
+ return error;
+ if ((error = pthread_mutex_init(&barrier->mutex, NULL)) != 0)
{
- int save_errno = errno;
-
pthread_cond_destroy(&barrier->cond);
- errno = save_errno;
-
- return -1;
+ return error;
}
return 0;