From: Radoslaw Zarzynski Date: Wed, 21 Sep 2016 12:27:49 +0000 (+0200) Subject: rgw: restrict the scope of RGWPostObj::data_pending. X-Git-Tag: v12.0.3~99^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c6c0d92371fd47863827321585e92c9617f1e7a1;p=ceph.git rgw: restrict the scope of RGWPostObj::data_pending. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 2f2efde1dd73..ab186d80f46f 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index a43652270662..be5c37f93b64 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -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 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; } }; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 4ff678c355c9..4aebd3165bf6 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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(); } diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 3b6ead19188a..463d6f523683 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -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* filter, RGWPutObjDataProcessor* cb) override; }; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 52d98e52bd1d..cd6c69decdbc 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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(); } diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index c60293501462..78d772103882 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -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);