]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rgw: add constructors to data structs; don't leak tags on races
authorGreg Farnum <gregory.farnum@dreamhost.com>
Mon, 17 Oct 2011 16:02:05 +0000 (09:02 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 20 Oct 2011 00:46:01 +0000 (17:46 -0700)
We were leaking tags on races before, since we cut out of the function
before clearing the tag. We don't do that any more.
Also, we now use a constructor for the dir entry structs so that
we don't follow the wrong paths (based on random memory) for
brand new objects.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/cls_rgw.cc
src/rgw/rgw_cls_api.h

index f1252a31188aa9e28c583be43db26bff76179dc0..3135f1e8e23d0449cdcd4222ab8443e202f8eadf 100644 (file)
@@ -214,10 +214,7 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
     bufferlist::iterator cur_iter = current_entry.begin();
     ::decode(entry, cur_iter);
     CLS_LOG("rgw_bucket_complete_op(): existing entry: epoch=%lld\n", entry.epoch);
-    if (op.epoch <= entry.epoch) {
-      CLS_LOG("rgw_bucket_complete_op(): skipping request, old epoch\n");
-      return 0;
-    }
+
     if (entry.exists) {
       struct rgw_bucket_category_stats& stats = header.stats[entry.meta.category];
       stats.num_entries--;
@@ -235,6 +232,11 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
     entry.pending_map.erase(pinter);
   }
 
+  if (op.epoch <= entry.epoch) {
+    CLS_LOG("rgw_bucket_complete_op(): skipping request, old epoch\n");
+    return 0;
+  }
+
   bufferlist op_bl;
 
   switch (op.op) {
index c078cb80bc78e4cd415608f643b90676a283adbb..db68ba9a9e5e3ade51914c95bdbe32191bfd8ec3 100644 (file)
@@ -54,6 +54,9 @@ struct rgw_bucket_dir_entry_meta {
   string owner_display_name;
   string tag;
 
+  rgw_bucket_dir_entry_meta() :
+  category(0), size(0) { mtime.set_from_double(0); }
+
   void encode(bufferlist &bl) const {
     __u8 struct_v = 1;
     ::encode(struct_v, bl);
@@ -84,6 +87,9 @@ struct rgw_bucket_dir_entry {
   struct rgw_bucket_dir_entry_meta meta;
   map<string, struct rgw_bucket_pending_info> pending_map;
 
+  rgw_bucket_dir_entry() :
+    epoch(0), exists(false) {}
+
   void encode(bufferlist &bl) const {
     __u8 struct_v = 1;
     ::encode(struct_v, bl);