]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephsqlite: fix unconditional success bug in CheckReservedLock 42630/head
authormark15213 <shuaiw2@andrew.cmu.edu>
Wed, 4 Aug 2021 13:02:32 +0000 (21:02 +0800)
committermark15213 <shuaiw2@andrew.cmu.edu>
Wed, 4 Aug 2021 15:27:23 +0000 (23:27 +0800)
we don't want to set result to zero at the end.
Otherwise, the if above would be useless and the function cannot be used to check the reserved lock.

Fixes: https://tracker.ceph.com/issues/52001
Signed-off-by: Shuai Wang <shuaiw2@andrew.cmu.edu>
src/libcephsqlite.cc

index 25782ff93974f8bf5ee95f8a6e77137561aa594b..9765a933f3502e790b21f5067e02ee7d16930f84 100644 (file)
@@ -255,6 +255,7 @@ static int CheckReservedLock(sqlite3_file *file, int *result)
   auto f = (cephsqlite_file*)file;
   auto start = ceph::coarse_mono_clock::now();
   df(5) << dendl;
+  *result = 0;
 
   auto& lock = f->lock;
   if (lock > SQLITE_LOCK_SHARED) {
@@ -265,7 +266,6 @@ static int CheckReservedLock(sqlite3_file *file, int *result)
   f->io.rs->print_lockers(*_dout);
   *_dout << dendl;
 
-  *result = 0;
   auto end = ceph::coarse_mono_clock::now();
   getdata(f->vfs).logger->tinc(P_OPF_CHECKRESERVEDLOCK, end-start);
   return SQLITE_OK;