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