]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWRESTPostResource takes param_list_t for RGWPostRESTResourceCR
authorCasey Bodley <cbodley@redhat.com>
Wed, 4 Nov 2015 21:57:34 +0000 (16:57 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:29 +0000 (16:13 -0800)
RGWPostRESTResourceCR needs to make a copy of the parameters given to
its constructor, because it doesn't use them until send_request(). this
results in a segfault when the given parameter list is on the stack

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_cr_rest.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index 4403977f42d14df153b05033eb7596f9e38f1527..02fa14eae40ae6a77c782fe74b12a88d8a4119ab 100644 (file)
@@ -54,17 +54,20 @@ class RGWPostRESTResourceCR : public RGWSimpleCoroutine {
   RGWRESTConn *conn;
   RGWHTTPManager *http_manager;
   string path;
-  rgw_http_param_pair *params;
+  param_list_t params;
   T *result;
   S input;
 
   RGWRESTPostResource *http_op;
 
 public:
-  RGWPostRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn, RGWHTTPManager *_http_manager,
-                       const string& _path, rgw_http_param_pair *_params, S& _input,
-                       T *_result) : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
-                                      path(_path), params(_params), result(_result), input(_input), http_op(NULL) {}
+  RGWPostRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                        RGWHTTPManager *_http_manager, const string& _path,
+                        rgw_http_param_pair *_params, S& _input, T *_result)
+    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
+      path(_path), params(make_param_list(_params)), result(_result),
+      input(_input), http_op(NULL)
+  {}
 
   int send_request() {
     http_op = new RGWRESTPostResource(conn, path, params, NULL, http_manager);
index ddff7fcba18ac6f652b73ed3ca2e62767bff5c34..3caa437614542e59d48c35dc67ac424ef3956e3e 100644 (file)
@@ -264,6 +264,22 @@ RGWRESTPostResource::RGWRESTPostResource(RGWRESTConn *_conn,
   : cct(_conn->get_ctx()), conn(_conn), resource(_resource),
     params(make_param_list(pp)), cb(bl), mgr(_mgr),
     req(cct, "POST", conn->get_url(), &cb, NULL, NULL)
+{
+  init_common(extra_headers);
+}
+
+RGWRESTPostResource::RGWRESTPostResource(RGWRESTConn *_conn,
+                                         const string& _resource,
+                                        param_list_t& params,
+                                         param_list_t *extra_headers,
+                                         RGWHTTPManager *_mgr)
+  : cct(_conn->get_ctx()), conn(_conn), resource(_resource), params(params),
+    cb(bl), mgr(_mgr), req(cct, "POST", conn->get_url(), &cb, NULL, NULL)
+{
+  init_common(extra_headers);
+}
+
+void RGWRESTPostResource::init_common(param_list_t *extra_headers)
 {
   params.push_back(param_pair_t(RGW_SYS_PARAM_PREFIX "zonegroup", conn->get_zonegroup()));
 
index b4e173652d22b04df552556363a9bf2a839167db..7c602bc16f26073971ab998c1feb1f20d84a916c 100644 (file)
@@ -264,6 +264,8 @@ class RGWRESTPostResource : public RefCountedObject {
   RGWHTTPManager *mgr;
   RGWRESTStreamRWRequest req;
 
+  void init_common(param_list_t *extra_headers);
+
 public:
   RGWRESTPostResource(RGWRESTConn *_conn,
                      const string& _resource,
@@ -271,6 +273,12 @@ public:
                      param_list_t *extra_headers,
                      RGWHTTPManager *_mgr);
 
+  RGWRESTPostResource(RGWRESTConn *_conn,
+                     const string& _resource,
+                     param_list_t& params,
+                     param_list_t *extra_headers,
+                     RGWHTTPManager *_mgr);
+
   void set_user_info(void *user_info) {
     req.set_user_info(user_info);
   }