Whamcloud - gitweb
LU-2744 build: fix 'data race condition' issues 67/6567/4
authorSebastien Buisson <sebastien.buisson@bull.net>
Thu, 6 Jun 2013 12:34:32 +0000 (14:34 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 17 Aug 2013 06:15:41 +0000 (06:15 +0000)
Fix 'data race condition' defects found by Coverity version
6.5.0:
Data race condition (MISSING_LOCK)
Accessing variable without holding lock. Elsewhere,
this variable is accessed with lock held.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: Ia9bad7782b6289e84c11e7998957c732508e10a5
Reviewed-on: http://review.whamcloud.com/6567
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Liang Zhen <liang.zhen@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/selftest/conrpc.c

index 27ad326..a7729ed 100644 (file)
@@ -949,8 +949,12 @@ lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
                return status;
 
        if (!trans->tas_feats_updated) {
-               trans->tas_feats_updated = 1;
-               trans->tas_features = reply->msg_ses_feats;
+               spin_lock(&console_session.ses_rpc_lock);
+               if (!trans->tas_feats_updated) { /* recheck with lock */
+                       trans->tas_feats_updated = 1;
+                       trans->tas_features = reply->msg_ses_feats;
+               }
+               spin_unlock(&console_session.ses_rpc_lock);
        }
 
        if (reply->msg_ses_feats != trans->tas_features) {