summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2014-04-14 11:39:24 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2014-04-14 13:00:51 +0200
commit7236b92857cb8a0207376d1349e42ba26172a519 (patch)
tree62cc23911a0ccee8ef95aa3bea2f13aba0d947cb
parent7075656034858e8f825635c8e8a6a0e5122924ae (diff)
downloadlvm2-7236b92857cb8a0207376d1349e42ba26172a519.tar.gz
clvmd: improve mutex usage in request_timed_out
Use mutex to access localsock values, so check num_replies when the thread is not yet finished. Check for threadid prior the mutex taking (though this check is probably not really needed)
-rw-r--r--WHATS_NEW1
-rw-r--r--daemons/clvmd/clvmd.c20
2 files changed, 13 insertions, 8 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 19ee0a771..a90906e34 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Use mutex to check number of replies in request_timed_out() in clvmd.
Drop usage of extra reply_mutex for localsock in clvmd.
Protect manipulation with finished flag with mutex in clvmd.
Shift mutex creation and destroy for localsock in clvmd to correct place.
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index b70543b14..ec24be9b9 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -812,16 +812,20 @@ static void request_timed_out(struct local_client *client)
DEBUGLOG("Request timed-out. padding\n");
clops->cluster_do_node_callback(client, timedout_callback);
- if (client->bits.localsock.num_replies !=
- client->bits.localsock.expected_replies) {
+ if (!client->bits.localsock.threadid)
+ return;
+
+ pthread_mutex_lock(&client->bits.localsock.mutex);
+
+ if (!client->bits.localsock.finished &&
+ (client->bits.localsock.num_replies !=
+ client->bits.localsock.expected_replies)) {
/* Post-process the command */
- if (client->bits.localsock.threadid) {
- pthread_mutex_lock(&client->bits.localsock.mutex);
- client->bits.localsock.state = POST_COMMAND;
- pthread_cond_signal(&client->bits.localsock.cond);
- pthread_mutex_unlock(&client->bits.localsock.mutex);
- }
+ client->bits.localsock.state = POST_COMMAND;
+ pthread_cond_signal(&client->bits.localsock.cond);
}
+
+ pthread_mutex_unlock(&client->bits.localsock.mutex);
}
/* This is where the real work happens */