From: Radoslaw Zarzynski Date: Thu, 4 May 2017 15:50:04 +0000 (+0200) Subject: rgw: use std::make_shared for AWSv4 completers creation. X-Git-Tag: v12.1.0~155^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=503d6878e0a156855b632b757c7785a6b6079d6e;p=ceph.git rgw: use std::make_shared for AWSv4 completers creation. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index bb7b00428f2e..79446fe82d52 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -1062,12 +1062,11 @@ AWSv4ComplMulti::create(const req_state* const s, const auto signing_key = \ rgw::auth::s3::get_v4_signing_key(s->cct, credential_scope, *secret_key); - return rgw::auth::Completer::cmplptr_t( - new AWSv4ComplMulti(s, - std::move(date), - std::move(credential_scope), - std::move(seed_signature), - signing_key)); + return std::make_shared(s, + std::move(date), + std::move(credential_scope), + std::move(seed_signature), + signing_key); } size_t AWSv4ComplSingle::recv_body(char* const buf, const size_t max) @@ -1117,7 +1116,7 @@ rgw::auth::Completer::cmplptr_t AWSv4ComplSingle::create(const req_state* const s, const boost::optional&) { - return rgw::auth::Completer::cmplptr_t(new AWSv4ComplSingle(s)); + return std::make_shared(s); } } /* namespace s3 */ diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index 4ea23eb0748d..6b3b33bf2a57 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -203,6 +203,12 @@ class AWSv4ComplMulti : public rgw::auth::Completer, SHA256* sha256_hash; std::string prev_chunk_signature; + bool is_signature_mismatched(); + std::string calc_chunk_signature(const std::string& payload_hash) const; + +public: + /* We need the constructor to be public because of the std::make_shared that + * is employed by the create() method. */ AWSv4ComplMulti(const req_state* const s, std::string date, std::string credential_scope, @@ -221,10 +227,6 @@ class AWSv4ComplMulti : public rgw::auth::Completer, prev_chunk_signature(std::move(seed_signature)) { } - bool is_signature_mismatched(); - std::string calc_chunk_signature(const std::string& payload_hash) const; - -public: ~AWSv4ComplMulti() { if (sha256_hash) { calc_hash_sha256_close_stream(&sha256_hash); @@ -256,10 +258,12 @@ class AWSv4ComplSingle : public rgw::auth::Completer, const char* const expected_request_payload_hash; ceph::crypto::SHA256* sha256_hash = nullptr; - /* Defined in rgw_auth_s3.cc because of get_v4_exp_payload_hash(). */ +public: + /* Defined in rgw_auth_s3.cc because of get_v4_exp_payload_hash(). We need + * the constructor to be public because of the std::make_shared employed by + * the create() method. */ AWSv4ComplSingle(const req_state* const s); -public: ~AWSv4ComplSingle() { if (sha256_hash) { calc_hash_sha256_close_stream(&sha256_hash);