]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rgw: don't zero out error code before reading value
authorYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Sat, 14 Apr 2012 06:17:51 +0000 (23:17 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 16 Apr 2012 19:32:51 +0000 (12:32 -0700)
We were zeroing the return code before reading it.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
src/cls_rgw.cc

index a406a618541ca0ca33eb7fe9f13774ed35077a17..06746d512705be4ed287372d459660bc9a80bc1b 100644 (file)
@@ -140,18 +140,25 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist
   if (rc < 0 && rc != -ENOENT)
     return rc;
 
+  struct rgw_bucket_dir_entry entry;
+
+  bool noent = (rc == -ENOENT);
+
   rc = 0;
 
-  struct rgw_bucket_dir_entry entry;
-  if (rc != -ENOENT) {
+  if (!noent) {
     try {
       bufferlist::iterator biter = cur_value.begin();
       ::decode(entry, biter);
     } catch (buffer::error& err) {
       CLS_LOG("ERROR: rgw_bucket_prepare_op(): failed to decode entry\n");
       /* ignoring error */
+
+      noent = true;
     }
-  } else { // no entry, initialize fields
+  }
+
+  if (noent) { // no entry, initialize fields
     entry.name = op.name;
     entry.epoch = 0;
     entry.exists = false;
@@ -243,7 +250,6 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
   }
 
   bufferlist op_bl;
-
   if (cancel) {
     if (op.tag.size()) {
       bufferlist new_key_bl;