master - clvmd: improve mutex usage in request_timed_out
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7236b92857cb8a0207376d1349e42ba26172a519 Commit: 7236b92857cb8a0207376d1349e42ba26172a519 Parent: 7075656034858e8f825635c8e8a6a0e5122924ae Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Apr 14 11:39:24 2014 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Apr 14 13:00:51 2014 +0200
clvmd: improve mutex usage in request_timed_out
Use mutex to access localsock values, so checknum_replies when the thread is not yet finished.
Check for threadid prior the mutex taking
(though this check is probably not really needed)
--- WHATS_NEW | 1 + daemons/clvmd/clvmd.c | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-)
WHATS_NEW +1 -0
@@ -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.
daemons/clvmd/clvmd.c +12 -8
@@ -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 */