cluster: RHEL6 - rgmanager: Fix for double pthread_mutex_unlock() calls

Ryan McCabe rmccabe at fedoraproject.org
Wed Jul 17 14:49:11 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=3e62b5680e917955df9bcb2ca627b0a656fe5b52
Commit:        3e62b5680e917955df9bcb2ca627b0a656fe5b52
Parent:        ceb12b85b625d57d0d219e55e2e179192fee53d6
Author:        Ryan McCabe <rmccabe at redhat.com>
AuthorDate:    Fri Jul 12 15:36:35 2013 -0400
Committer:     Ryan McCabe <rmccabe at redhat.com>
CommitterDate: Wed Jul 17 10:49:05 2013 -0400

rgmanager: Fix for double pthread_mutex_unlock() calls

Fix a few places where pthread_mutex_unlock() could be called
on an unlocked mutex.

Resolves: rhbz#983296

Signed-off-by: Ryan McCabe <rmccabe at redhat.com>
---
 rgmanager/src/clulib/vft.c       |    4 ++--
 rgmanager/src/daemons/rg_event.c |    5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/rgmanager/src/clulib/vft.c b/rgmanager/src/clulib/vft.c
index 0113bad..ad1f468 100644
--- a/rgmanager/src/clulib/vft.c
+++ b/rgmanager/src/clulib/vft.c
@@ -1007,7 +1007,6 @@ vf_key_init_nt(const char *keyid, int timeout, vf_vote_cb_t vote_cb,
 	newnode = kn_find_key(keyid);
 	if (newnode) {
 		printf("Key %s already initialized\n", keyid);
-		pthread_mutex_unlock(&key_list_mutex);
 		return -1;
 	}
 
@@ -1015,7 +1014,6 @@ vf_key_init_nt(const char *keyid, int timeout, vf_vote_cb_t vote_cb,
 
 	if (newnode == NULL) {
 		fprintf(stderr, "malloc fail3 err=%d\n", errno);
-		pthread_mutex_unlock(&key_list_mutex);
 		return -1;
 	}
 
@@ -1493,6 +1491,8 @@ vf_read(cluster_member_list_t *membership, const char *keyid, uint64_t *view,
 			pthread_mutex_unlock(&vf_mutex);
 			return l;
 		}
+
+		pthread_mutex_lock(&key_list_mutex);
 	}
 
 	*data = malloc(key_node->kn_datalen);
diff --git a/rgmanager/src/daemons/rg_event.c b/rgmanager/src/daemons/rg_event.c
index 6b1023a..4a747e0 100644
--- a/rgmanager/src/daemons/rg_event.c
+++ b/rgmanager/src/daemons/rg_event.c
@@ -332,9 +332,8 @@ event_master(void)
 			//logt_print(LOG_DEBUG, "%d is master\n", mi->m_nodeid);
 			goto out;
 		}
-	}
-
-	pthread_mutex_unlock(&mi_mutex);
+	} else
+		pthread_mutex_unlock(&mi_mutex);
 
 	memset(&_master_lock, 0, sizeof(_master_lock));
 	if (clu_lock(LKM_EXMODE, &_master_lock, LKF_NOQUEUE,


More information about the cluster-commits mailing list