]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/KeyValueDB: return -ENOENT if key doesn't exist
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Wed, 8 Apr 2015 13:43:29 +0000 (21:43 +0800)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 21:03:54 +0000 (17:03 -0400)
Previous code return 0 in all cases, caller doesn't
know if the key is exists in the db.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/os/KeyValueDB.h

index 80fdceca81658f541b301c2792dbdcfa49289bfa..028243667dbb1c5665d662784383bfeec0bcccd0 100644 (file)
@@ -93,7 +93,12 @@ public:
     ks.insert(key);
     map<string,bufferlist> om;
     int r = get(prefix, ks, &om);
-    *value = om[key];
+    if (om.find(key) != om.end()) {
+      *value = om[key];
+    } else {
+      *value = bufferlist();
+      r = -ENOENT;
+    }
     return r;
   }