diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2014-04-14 11:39:24 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2014-04-14 13:00:51 +0200 |
commit | 7236b92857cb8a0207376d1349e42ba26172a519 (patch) | |
tree | 62cc23911a0ccee8ef95aa3bea2f13aba0d947cb /daemons/clvmd | |
parent | 7075656034858e8f825635c8e8a6a0e5122924ae (diff) | |
download | lvm2-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)
Diffstat (limited to 'daemons/clvmd')
-rw-r--r-- | daemons/clvmd/clvmd.c | 20 |
1 files changed, 12 insertions, 8 deletions
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 */ |