|
|
887953 |
From c285acf172d42271d87eb069045ea70bce97b0b1 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
887953 |
Date: Mon, 23 Apr 2018 21:04:58 +0530
|
|
|
887953 |
Subject: [PATCH 428/444] libglusterfs/syncop: Handle barrier_{init/destroy} in
|
|
|
887953 |
error cases
|
|
|
887953 |
|
|
|
887953 |
> Upstream: https://review.gluster.org/19927
|
|
|
887953 |
> BUG: 1568521
|
|
|
887953 |
> Change-Id: I53e60cfcaa7f8edfa5eca47307fa99f10ee64505
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I53e60cfcaa7f8edfa5eca47307fa99f10ee64505
|
|
|
887953 |
BUG: 1520882
|
|
|
887953 |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/154862
|
|
|
887953 |
Tested-by: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
887953 |
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
libglusterfs/src/syncop.c | 30 ++++++++++++++++++++++++++----
|
|
|
887953 |
libglusterfs/src/syncop.h | 1 +
|
|
|
887953 |
2 files changed, 27 insertions(+), 4 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
|
|
|
887953 |
index ac40a1d..81d73b2 100644
|
|
|
887953 |
--- a/libglusterfs/src/syncop.c
|
|
|
887953 |
+++ b/libglusterfs/src/syncop.c
|
|
|
887953 |
@@ -1087,30 +1087,52 @@ synclock_unlock (synclock_t *lock)
|
|
|
887953 |
int
|
|
|
887953 |
syncbarrier_init (struct syncbarrier *barrier)
|
|
|
887953 |
{
|
|
|
887953 |
+ int ret = 0;
|
|
|
887953 |
if (!barrier) {
|
|
|
887953 |
errno = EINVAL;
|
|
|
887953 |
return -1;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
- pthread_cond_init (&barrier->cond, 0);
|
|
|
887953 |
+ ret = pthread_cond_init (&barrier->cond, 0);
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
+ errno = ret;
|
|
|
887953 |
+ return -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
barrier->count = 0;
|
|
|
887953 |
barrier->waitfor = 0;
|
|
|
887953 |
INIT_LIST_HEAD (&barrier->waitq);
|
|
|
887953 |
|
|
|
887953 |
- return pthread_mutex_init (&barrier->guard, 0);
|
|
|
887953 |
+ ret = pthread_mutex_init (&barrier->guard, 0);
|
|
|
887953 |
+ if (ret) {
|
|
|
887953 |
+ (void)pthread_cond_destroy (&barrier->cond);
|
|
|
887953 |
+ errno = ret;
|
|
|
887953 |
+ return -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ barrier->initialized = _gf_true;
|
|
|
887953 |
+ return 0;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
|
|
|
887953 |
int
|
|
|
887953 |
syncbarrier_destroy (struct syncbarrier *barrier)
|
|
|
887953 |
{
|
|
|
887953 |
+ int ret = 0;
|
|
|
887953 |
+ int ret1 = 0;
|
|
|
887953 |
if (!barrier) {
|
|
|
887953 |
errno = EINVAL;
|
|
|
887953 |
return -1;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
- pthread_cond_destroy (&barrier->cond);
|
|
|
887953 |
- return pthread_mutex_destroy (&barrier->guard);
|
|
|
887953 |
+ if (barrier->initialized) {
|
|
|
887953 |
+ ret = pthread_cond_destroy (&barrier->cond);
|
|
|
887953 |
+ ret1 = pthread_mutex_destroy (&barrier->guard);
|
|
|
887953 |
+ barrier->initialized = _gf_false;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ if (ret || ret1) {
|
|
|
887953 |
+ errno = ret?ret:ret1;
|
|
|
887953 |
+ return -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
+ return 0;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
|
|
|
887953 |
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
|
|
|
887953 |
index 5b5ad4e..9ab5ee8 100644
|
|
|
887953 |
--- a/libglusterfs/src/syncop.h
|
|
|
887953 |
+++ b/libglusterfs/src/syncop.h
|
|
|
887953 |
@@ -134,6 +134,7 @@ typedef struct synclock synclock_t;
|
|
|
887953 |
|
|
|
887953 |
|
|
|
887953 |
struct syncbarrier {
|
|
|
887953 |
+ gf_boolean_t initialized; /*Set on successful initialization*/
|
|
|
887953 |
pthread_mutex_t guard; /* guard the remaining members, pair @cond */
|
|
|
887953 |
pthread_cond_t cond; /* waiting non-synctasks */
|
|
|
887953 |
struct list_head waitq; /* waiting synctasks */
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|