File bug-1041424_clvmd-add-mutex-protection-for-cpg_-call.patch of Package lvm2.7683
From f2b9e34e08951dbb9798508ed0e84b6c376fa666 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Sat, 4 Feb 2017 14:47:27 +0100
Subject: [PATCH 10/10] clvmd: add mutex protection for cpg_ call
The library for corosync multicasting is not supporting multithread
usage - add local mutex to avoid parallel call of cpg_mcast_joined().
(cherry picked from commit dae4f53acb269219e876c229c8f034fcdaf3ff5a)
---
daemons/clvmd/clvmd-corosync.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/daemons/clvmd/clvmd-corosync.c b/daemons/clvmd/clvmd-corosync.c
index 55b3884..ec0da50 100644
--- a/daemons/clvmd/clvmd-corosync.c
+++ b/daemons/clvmd/clvmd-corosync.c
@@ -536,6 +536,7 @@ static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
static int _cluster_send_message(const void *buf, int msglen, const char *csid,
const char *errtext)
{
+ static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
struct iovec iov[2];
cs_error_t err;
int target_node;
@@ -550,7 +551,10 @@ static int _cluster_send_message(const void *buf, int msglen, const char *csid,
iov[1].iov_base = (char *)buf;
iov[1].iov_len = msglen;
+ pthread_mutex_lock(&_mutex);
err = cpg_mcast_joined(cpg_handle, CPG_TYPE_AGREED, iov, 2);
+ pthread_mutex_unlock(&_mutex);
+
return cs_to_errno(err);
}
--
2.10.2