]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client/Client.cc: fix/silence "logically dead code" CID-Error 291/head
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 16 May 2013 17:49:06 +0000 (19:49 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 16 May 2013 17:49:06 +0000 (19:49 +0200)
Fix handling of 'safe' and the conditions after calling file_flush().

CID 1019548 (#1 of 1): Logically dead code (DEADCODE)
  dead_error_begin: Execution cannot reach this statement "flock.Unlock();"

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/client/Client.cc

index 6947f8b43060ee0defd8f38b32ff609794367f5c..bed2c450f2f01dc2506a27ce6235661f5ab74154 100644 (file)
@@ -2720,18 +2720,17 @@ void Client::_flush_range(Inode *in, int64_t offset, uint64_t size)
   Cond cond;
   bool safe = false;
   Context *onflush = new C_SafeCond(&flock, &cond, &safe);
-  safe = objectcacher->file_flush(&in->oset, &in->layout, in->snaprealm->get_snap_context(),
-                                 offset, size, onflush);
-  if (safe)
-    return;
-
-  // wait for flush
-  client_lock.Unlock();
-  flock.Lock();
-  while (!safe)
-    cond.Wait(flock);
-  flock.Unlock();
-  client_lock.Lock();
+  bool ret = objectcacher->file_flush(&in->oset, &in->layout, in->snaprealm->get_snap_context(),
+                                     offset, size, onflush);
+  if (!ret) {
+    // wait for flush
+    client_lock.Unlock();
+    flock.Lock();
+    while (!safe)
+      cond.Wait(flock);
+    flock.Unlock();
+    client_lock.Lock();
+  }
 }
 
 void Client::flush_set_callback(ObjectCacher::ObjectSet *oset)