]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: restrict the scope of RGWPostObj::data_pending.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 21 Sep 2016 12:27:49 +0000 (14:27 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 24 Apr 2017 15:32:15 +0000 (17:32 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h

index 2f2efde1dd7366a76ac9d91ad53b95c403c997d3..ab186d80f46ff027ae440205b24db1a7ebf19f1e 100644 (file)
@@ -3343,9 +3343,10 @@ void RGWPostObj::execute()
       }
     }
 
-    while (data_pending) {
-      bufferlist data;
-      len = get_data(data);
+    bool again;
+    do {
+      ceph::bufferlist data;
+      len = get_data(data, again);
 
       if (len < 0) {
         op_ret = len;
@@ -3365,7 +3366,7 @@ void RGWPostObj::execute()
         op_ret = -ERR_TOO_LARGE;
         return;
       }
-    }
+    } while (again);
 
     {
       bufferlist flush;
index a436522706629cb25631a749f3d35690804e1ac8..be5c37f93b6452252b2ccbd35ca62037a3426ec7 100644 (file)
@@ -1013,7 +1013,6 @@ protected:
   const char *supplied_md5_b64;
   const char *supplied_etag;
   string etag;
-  bool data_pending;
   string content_type;
   RGWAccessControlPolicy policy;
   map<string, bufferlist> attrs;
@@ -1030,8 +1029,7 @@ public:
                  len(0),
                  ofs(0),
                  supplied_md5_b64(nullptr),
-                 supplied_etag(nullptr),
-                 data_pending(false) {
+                 supplied_etag(nullptr) {
   }
 
   void emplace_attr(std::string&& key, buffer::list&& bl) {
@@ -1052,9 +1050,9 @@ public:
     return 0;
   }
   virtual int get_params() = 0;
-  virtual int get_data(bufferlist& bl) = 0;
+  virtual int get_data(ceph::bufferlist& bl, bool& again) = 0;
   void send_response() override = 0;
-  const string name() override { return "post_obj"; }
+  const std::string name() override { return "post_obj"; }
   RGWOpType get_type() override { return RGW_OP_POST_OBJ; }
   uint32_t op_mask() override { return RGW_OP_TYPE_WRITE; }
 };
index 4ff678c355c9985e8b0e0226e51715b98c1a7881..4aebd3165bf68ebdcce8a43be380d4dcfd82acee 100644 (file)
@@ -1559,7 +1559,6 @@ int RGWPostObj_ObjStore_S3::get_params()
        filename = iter->second;
       }
       parts[part.name] = part;
-      data_pending = true;
       break;
     }
 
@@ -1766,7 +1765,7 @@ int RGWPostObj_ObjStore_S3::complete_get_params()
   return 0;
 }
 
-int RGWPostObj_ObjStore_S3::get_data(bufferlist& bl)
+int RGWPostObj_ObjStore_S3::get_data(ceph::bufferlist& bl, bool& again)
 {
   bool boundary;
   bool done;
@@ -1778,8 +1777,6 @@ int RGWPostObj_ObjStore_S3::get_data(bufferlist& bl)
   }
 
   if (boundary) {
-    data_pending = false;
-
     if (!done) {
       /* Reached end of data, let's drain the rest of the params */
       r = complete_get_params();
@@ -1789,6 +1786,7 @@ int RGWPostObj_ObjStore_S3::get_data(bufferlist& bl)
     }
   }
 
+  again = !boundary;
   return bl.length();
 }
 
index 3b6ead19188a3b3969b8813a67a327f70d51f427..463d6f523683f37a6f6c7aa0e4fad62588823609 100644 (file)
@@ -221,7 +221,7 @@ public:
   int complete_get_params();
 
   void send_response() override;
-  int get_data(bufferlist& bl) override;
+  int get_data(ceph::bufferlist& bl, bool& again) override;
   int get_encrypt_filter(std::unique_ptr<RGWPutObjDataProcessor>* filter,
                          RGWPutObjDataProcessor* cb) override;
 };
index 52d98e52bd1d0f8859154feac8709589993189a5..cd6c69decdbc5765fdbe8c74eecc46bf7e5b3ad9 100644 (file)
@@ -1827,9 +1827,6 @@ int RGWFormPost::get_params()
       /* First data part ahead. */
       current_data_part = std::move(part);
 
-      /* Tell RGWPostObj::execute() that it has some data to put. */
-      data_pending = true;
-
       /* Stop the iteration. We can assume that all control parts have been
        * already parsed. The rest of HTTP body should contain data parts
        * only. They will be picked up by ::get_data(). */
@@ -1895,10 +1892,6 @@ bool RGWFormPost::is_next_file_to_upload()
 
       if (std::end(params) != params.find("filename")) {
         current_data_part = std::move(part);
-
-        /* Tell RGWPostObj::execute() that it has some data to put. */
-        data_pending = true;
-
         return true;
       }
     }
@@ -1907,7 +1900,7 @@ bool RGWFormPost::is_next_file_to_upload()
   return false;
 }
 
-int RGWFormPost::get_data(ceph::bufferlist& bl)
+int RGWFormPost::get_data(ceph::bufferlist& bl, bool& again)
 {
   bool boundary;
 
@@ -1917,10 +1910,8 @@ int RGWFormPost::get_data(ceph::bufferlist& bl)
     return r;
   }
 
-  if (boundary) {
-    data_pending = false;
-    current_data_part = boost::none;
-  }
+  /* Tell RGWPostObj::execute() that it has some data to put. */
+  again = !boundary;
 
   return bl.length();
 }
index c6029350146266e44539fafb8edf3d7167084d9e..78d7721038826eee4f35af2a08359b1dfdfff598 100644 (file)
@@ -261,7 +261,7 @@ public:
             RGWHandler* dialect_handler) override;
 
   int get_params() override;
-  int get_data(ceph::bufferlist& bl) override;
+  int get_data(ceph::bufferlist& bl, bool& again) override;
   void send_response() override;
 
   static bool is_formpost_req(req_state* const s);