From be17da5e1d13bbe34839e28410d238c93389c847 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 8 Sep 2015 13:45:05 -0400 Subject: [PATCH] rgw: delay allocation of RGWPeriod RGWOp_Period_Get and _Post don't have a valid RGWRados pointer until they get the init() call, so the constructors were passing NULL to RGWPeriod Signed-off-by: Casey Bodley --- src/rgw/rgw_rest_config.cc | 11 +++++++---- src/rgw/rgw_rest_config.h | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc index d70c6f07a93d4..aac2f5d70f6b9 100644 --- a/src/rgw/rgw_rest_config.cc +++ b/src/rgw/rgw_rest_config.cc @@ -48,7 +48,8 @@ void RGWOp_Period_Get::execute() { epoch_t epoch = 0; RESTArgs::get_uint32(s, "epoch", 0, &epoch); - http_ret = period.init(period_id, epoch); + period = new RGWPeriod(g_ceph_context, store); + http_ret = period->init(period_id, epoch); if (http_ret < 0) { dout(5) << "failed to read period" << dendl; } @@ -62,7 +63,7 @@ void RGWOp_Period_Get::send_response() { if (http_ret < 0) return; - encode_json("period", period, s->formatter); + encode_json("period", *period, s->formatter); flusher.flush(); } @@ -71,7 +72,9 @@ void RGWOp_Period_Post::execute() { RESTArgs::get_string(s, "period_id", period_id, &period_id); epoch_t epoch = 0; RESTArgs::get_uint32(s, "epoch", 0, &epoch); - http_ret = period.init(period_id, epoch); + + period = new RGWPeriod(g_ceph_context, store); + http_ret = period->init(period_id, epoch); if (http_ret < 0) { dout(5) << "failed to read period" << dendl; } @@ -85,7 +88,7 @@ void RGWOp_Period_Post::send_response() { if (http_ret < 0) return; - encode_json("period", period, s->formatter); + encode_json("period", *period, s->formatter); flusher.flush(); } diff --git a/src/rgw/rgw_rest_config.h b/src/rgw/rgw_rest_config.h index 64325e18d0f7d..88e674aba6d77 100644 --- a/src/rgw/rgw_rest_config.h +++ b/src/rgw/rgw_rest_config.h @@ -31,10 +31,10 @@ public: }; class RGWOp_Period_Get : public RGWRESTOp { - RGWPeriod period; + RGWPeriod *period; public: - RGWOp_Period_Get(): period(g_ceph_context, store) {} - ~RGWOp_Period_Get() {} + RGWOp_Period_Get() : period(NULL) {} + ~RGWOp_Period_Get() { delete period; } int verify_permission() { return 0; @@ -47,10 +47,10 @@ public: }; class RGWOp_Period_Post : public RGWRESTOp { - RGWPeriod period; + RGWPeriod *period; public: - RGWOp_Period_Post(): period(g_ceph_context, store) {} - ~RGWOp_Period_Post() {} + RGWOp_Period_Post() : period(NULL) {} + ~RGWOp_Period_Post() { delete period; } int verify_permission() { return 0; -- 2.39.5