From e524c586fd69a9a26bd6f3f7980e29616acc7035 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 17 Aug 2016 18:48:34 +0200 Subject: [PATCH] rgw: rename and split STREAM_IO into RESTFUL_IO and ACCOUNTING_IO. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_auth_s3.cc | 2 +- src/rgw/rgw_client_io.h | 11 +++++++++++ src/rgw/rgw_log.cc | 4 ---- src/rgw/rgw_rest.cc | 26 +++++++++++++------------- src/rgw/rgw_rest.h | 7 ------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index 8baa7992b18..62d7ddab10b 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -275,7 +275,7 @@ void rgw_create_s3_v4_canonical_request(struct req_state *s, const string& canon request_payload_hash = "UNSIGNED-PAYLOAD"; } else { if (s->aws4_auth_needs_complete) { - request_payload_hash = STREAM_IO(s)->grab_aws4_sha256_hash(); + request_payload_hash = RESTFUL_IO(s)->grab_aws4_sha256_hash(); } else { if (s->aws4_auth_streaming_mode) { request_payload_hash = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD"; diff --git a/src/rgw/rgw_client_io.h b/src/rgw/rgw_client_io.h index 32621459e75..5ca3adbc226 100644 --- a/src/rgw/rgw_client_io.h +++ b/src/rgw/rgw_client_io.h @@ -213,6 +213,17 @@ public: }; /* RGWRestfulIO */ +/* Type conversions to work around lack of req_state type hierarchy matching + * (e.g.) REST backends (may be replaced w/dynamic typed req_state). */ +static inline RGWRestfulIO* RESTFUL_IO(struct req_state* s) { + return static_cast(s->cio); +} + +static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) { + return dynamic_cast(s->cio); +} + + class RGWClientIOStreamBuf : public std::streambuf { protected: RGWRestfulIO &rio; diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index 84c66c420f4..49561735530 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -179,10 +179,6 @@ void rgw_log_usage_finalize() usage_logger = NULL; } -static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) { - return dynamic_cast(s->cio); -} - static void log_usage(struct req_state *s, const string& op_name) { if (s->system_request) /* don't log system user operations */ diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 0aa3c069e04..f5d6263fb21 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -280,7 +280,7 @@ static void dump_status(struct req_state *s, int status, { s->formatter->set_status(status, status_name); try { - STREAM_IO(s)->send_status(status, status_name); + RESTFUL_IO(s)->send_status(status, status_name); } catch (RGWRestfulIOEngine::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_status() returned err=" << e.value() << dendl; @@ -375,7 +375,7 @@ void dump_header(struct req_state* const s, const boost::string_ref& val) { try { - STREAM_IO(s)->send_header(name, val); + RESTFUL_IO(s)->send_header(name, val); } catch (RGWRestfulIOEngine::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_header() returned err=" << e.value() << dendl; @@ -414,7 +414,7 @@ void dump_header(struct req_state* const s, void dump_content_length(struct req_state* const s, const uint64_t len) { try { - STREAM_IO(s)->send_content_length(len); + RESTFUL_IO(s)->send_content_length(len); } catch (RGWRestfulIOEngine::Exception& e) { ldout(s->cct, 0) << "ERROR: s->cio->send_content_length() returned err=" << e.value() << dendl; @@ -425,9 +425,9 @@ void dump_content_length(struct req_state* const s, const uint64_t len) static void dump_chunked_encoding(struct req_state* const s) { try { - STREAM_IO(s)->send_chunked_transfer_encoding(); + RESTFUL_IO(s)->send_chunked_transfer_encoding(); } catch (RGWRestfulIOEngine::Exception& e) { - ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->send_chunked_transfer_encoding()" + ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_chunked_transfer_encoding()" << " returned err=" << e.what() << dendl; } } @@ -707,13 +707,13 @@ void end_header(struct req_state* s, RGWOp* op, const char *content_type, } try { - STREAM_IO(s)->complete_header(); + RESTFUL_IO(s)->complete_header(); } catch (RGWRestfulIOEngine::Exception& e) { - ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->complete_header() returned err=" + ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->complete_header() returned err=" << e.value() << dendl; } - STREAM_IO(s)->set_account(true); + ACCOUNTING_IO(s)->set_account(true); rgw_flush_formatter_and_reset(s, s->formatter); } @@ -785,7 +785,7 @@ void abort_early(struct req_state *s, RGWOp *op, int err_no, * x-amz-error-detail-Key: foo */ end_header(s, op, NULL, error_content.size(), false, true); - STREAM_IO(s)->send_body(error_content.c_str(), error_content.size()); + RESTFUL_IO(s)->send_body(error_content.c_str(), error_content.size()); } else { end_header(s, op); } @@ -797,9 +797,9 @@ void abort_early(struct req_state *s, RGWOp *op, int err_no, void dump_continue(struct req_state * const s) { try { - STREAM_IO(s)->send_100_continue(); + RESTFUL_IO(s)->send_100_continue(); } catch (RGWRestfulIOEngine::Exception& e) { - ldout(s->cct, 0) << "ERROR: STREAM_IO(s)->send_100_continue() returned err=" + ldout(s->cct, 0) << "ERROR: RESTFUL_IO(s)->send_100_continue() returned err=" << e.value() << dendl; } } @@ -833,7 +833,7 @@ int dump_body(struct req_state* const s, const std::size_t len) { try { - return STREAM_IO(s)->send_body(buf, len); + return RESTFUL_IO(s)->send_body(buf, len); } catch (RGWRestfulIOEngine::Exception& e) { return e.value(); } @@ -854,7 +854,7 @@ int recv_body(struct req_state* const s, const std::size_t max) { try { - return STREAM_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete); + return RESTFUL_IO(s)->recv_body(buf, max, s->aws4_auth_needs_complete); } catch (RGWRestfulIOEngine::Exception& e) { return e.value(); } diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index b70c33ac55e..37e70724072 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -30,13 +30,6 @@ extern void rgw_flush_formatter(struct req_state *s, extern int rgw_rest_read_all_input(struct req_state *s, char **data, int *plen, int max_len); -/* type conversions to work around lack of req_state type - * hierarchy matching (e.g.) REST backends (may be replaced w/dynamic - * typed req_state) */ -static inline RGWRestfulIO* STREAM_IO(struct req_state* s) { - return static_cast(s->cio); -} - template int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out, int max_len, bool *empty)