Skip to content

Commit

Permalink
rgw: rename and split STREAM_IO into RESTFUL_IO and ACCOUNTING_IO.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
  • Loading branch information
rzarzynski committed Aug 17, 2016
1 parent 2ac31ef commit 96a1f28
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/rgw/rgw_auth_s3.cc
Expand Up @@ -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";
Expand Down
11 changes: 11 additions & 0 deletions src/rgw/rgw_client_io.h
Expand Up @@ -213,6 +213,17 @@ class RGWRestfulIO : public RGWRestfulIOAccountingEngine<RGWRestfulIOEngine*> {
}; /* 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<RGWRestfulIO*>(s->cio);
}

static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) {
return dynamic_cast<RGWClientIOAccounter*>(s->cio);
}


class RGWClientIOStreamBuf : public std::streambuf {
protected:
RGWRestfulIO &rio;
Expand Down
4 changes: 0 additions & 4 deletions src/rgw/rgw_log.cc
Expand Up @@ -179,10 +179,6 @@ void rgw_log_usage_finalize()
usage_logger = NULL;
}

static inline RGWClientIOAccounter* ACCOUNTING_IO(struct req_state* s) {
return dynamic_cast<RGWClientIOAccounter*>(s->cio);
}

static void log_usage(struct req_state *s, const string& op_name)
{
if (s->system_request) /* don't log system user operations */
Expand Down
24 changes: 12 additions & 12 deletions src/rgw/rgw_rest.cc
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -683,7 +683,7 @@ void end_header(struct req_state* s, RGWOp* op, const char *content_type,
if (proposed_content_length != NO_CONTENT_LENGTH) {
dump_content_length(s, proposed_content_length);
} else {
STREAM_IO(s)->send_chunked_transfer_encoding();
RESTFUL_IO(s)->send_chunked_transfer_encoding();
}
}

Expand All @@ -692,13 +692,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);
}

Expand Down Expand Up @@ -770,7 +770,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);
}
Expand All @@ -782,9 +782,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;
}
}
Expand Down Expand Up @@ -818,7 +818,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();
}
Expand All @@ -839,7 +839,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();
}
Expand Down
7 changes: 0 additions & 7 deletions src/rgw/rgw_rest.h
Expand Up @@ -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<RGWRestfulIO*>(s->cio);
}

template <class T>
int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out,
int max_len, bool *empty)
Expand Down

0 comments on commit 96a1f28

Please sign in to comment.