1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

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)
This commit is contained in:
Zdenek Kabelac 2014-04-14 11:39:24 +02:00
parent 7075656034
commit 7236b92857
2 changed files with 13 additions and 8 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.107 - 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. Drop usage of extra reply_mutex for localsock in clvmd.
Protect manipulation with finished flag with mutex in clvmd. Protect manipulation with finished flag with mutex in clvmd.
Shift mutex creation and destroy for localsock in clvmd to correct place. Shift mutex creation and destroy for localsock in clvmd to correct place.

View File

@ -812,16 +812,20 @@ static void request_timed_out(struct local_client *client)
DEBUGLOG("Request timed-out. padding\n"); DEBUGLOG("Request timed-out. padding\n");
clops->cluster_do_node_callback(client, timedout_callback); clops->cluster_do_node_callback(client, timedout_callback);
if (client->bits.localsock.num_replies != if (!client->bits.localsock.threadid)
client->bits.localsock.expected_replies) { 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 */ /* Post-process the command */
if (client->bits.localsock.threadid) { client->bits.localsock.state = POST_COMMAND;
pthread_mutex_lock(&client->bits.localsock.mutex); pthread_cond_signal(&client->bits.localsock.cond);
client->bits.localsock.state = POST_COMMAND;
pthread_cond_signal(&client->bits.localsock.cond);
pthread_mutex_unlock(&client->bits.localsock.mutex);
}
} }
pthread_mutex_unlock(&client->bits.localsock.mutex);
} }
/* This is where the real work happens */ /* This is where the real work happens */