From 522352d4b123d66f7d0b57c287ed7367deba0f31 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 13 Aug 2018 12:20:07 -0700 Subject: features/changelog: Fix missing unlocks Addresses CID 1210981 Change-Id: Icd325588ae0639e09d924fdde171931dedd06ca6 updates: bz#789278 Signed-off-by: Vijay Bellur --- xlators/features/changelog/src/changelog-helpers.c | 10 ++++++---- xlators/features/changelog/src/changelog-helpers.h | 13 +++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'xlators/features/changelog/src') diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 4ab3c8429d1..81bd99bcb7d 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -1803,8 +1803,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, priv->dm.drain_wait_black == _gf_true) { ret = pthread_cond_signal ( &priv->dm.drain_black_cond); - CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, - out); + CHANGELOG_PTHREAD_ERROR_HANDLE_2 (ret, + out, + priv->dm.drain_black_mutex); gf_msg_debug (this->name, 0, "Signalled " "draining of black"); @@ -1821,8 +1822,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, priv->dm.drain_wait_white == _gf_true) { ret = pthread_cond_signal ( &priv->dm.drain_white_cond); - CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, - out); + CHANGELOG_PTHREAD_ERROR_HANDLE_2 (ret, + out, + priv->dm.drain_white_mutex); gf_msg_debug (this->name, 0, "Signalled " "draining of white"); diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index 39a792891dd..1551337c16f 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -675,6 +675,19 @@ resolve_pargfid_to_path (xlator_t *this, const uuid_t gfid, char **path, goto label; \ } \ } while (0) + +/* Log pthread error, unlock mutex and goto label */ +#define CHANGELOG_PTHREAD_ERROR_HANDLE_2(ret, label, mutex) do { \ + if (ret) { \ + gf_smsg (this->name, GF_LOG_ERROR, \ + 0, CHANGELOG_MSG_PTHREAD_ERROR, \ + "pthread error", "error=%d", ret, NULL); \ + ret = -1; \ + pthread_mutex_unlock (&mutex); \ + goto label; \ + } \ + } while (0) + /* End: Geo-Rep snapshot dependency changes */ #endif /* _CHANGELOG_HELPERS_H */ -- cgit