summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBabu Shanmugam <anbu@enovance.com>2013-06-27 20:14:30 +0530
committerBabu Shanmugam <anbu@enovance.com>2013-06-27 20:14:30 +0530
commit2591bc93013089d2df0af3bf3b31ce7d9da1f2f5 (patch)
treec234bad72e5e36b2063a530f3b1d43605ab4105a
parentcaf94b72d242a8d665785f34afbe4b739bbc6ef0 (diff)
downloadceph-2591bc93013089d2df0af3bf3b31ce7d9da1f2f5.tar.gz
Used rgw_rest_read_all_input instead of a private function
Signed-off-by: Babu Shanmugam <anbu@enovance.com>
-rw-r--r--src/rgw/rgw_common.h4
-rw-r--r--src/rgw/rgw_rest_replica_log.cc60
-rw-r--r--src/rgw/rgw_rest_replica_log.h6
3 files changed, 13 insertions, 57 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index 8f213638f82..8ceafbebeb6 100644
--- a/src/rgw/rgw_common.h
+++ b/src/rgw/rgw_common.h
@@ -614,7 +614,7 @@ struct RGWBucketInfo
::encode(owner, bl);
::encode(flags, bl);
::encode(region, bl);
- ::encode((uint32_t)creation_time, bl);
+ ::encode((uint64_t)creation_time, bl);
::encode(placement_rule, bl);
ENCODE_FINISH(bl);
}
@@ -628,7 +628,7 @@ struct RGWBucketInfo
if (struct_v >= 5)
::decode(region, bl);
if (struct_v >= 6)
- ::decode((uint32_t&)creation_time, bl);
+ ::decode((uint64_t&)creation_time, bl);
if (struct_v >= 7)
::decode(placement_rule, bl);
DECODE_FINISH(bl);
diff --git a/src/rgw/rgw_rest_replica_log.cc b/src/rgw/rgw_rest_replica_log.cc
index 5dcf498ae46..fc1ef9c52cb 100644
--- a/src/rgw/rgw_rest_replica_log.cc
+++ b/src/rgw/rgw_rest_replica_log.cc
@@ -24,51 +24,7 @@
#include "common/errno.h"
#define dout_subsys ceph_subsys_rgw
-
-static int get_data(req_state *s, bufferlist& bl) {
- size_t cl = 0;
- char *data;
- int read_len;
-
- if (s->length)
- cl = atoll(s->length);
- if (cl) {
- data = (char *)malloc(cl + 1);
- if (!data) {
- return -ENOMEM;
- }
- int r = s->cio->read(data, cl, &read_len);
- if (cl != (size_t)read_len) {
- dout(10) << "cio->read incomplete" << dendl;
- }
- if (r < 0) {
- free(data);
- return r;
- }
- bl.append(data, read_len);
- } else {
- int chunk_size = CEPH_PAGE_SIZE;
- const char *enc = s->info.env->get("HTTP_TRANSFER_ENCODING");
- if (!enc || strcmp(enc, "chunked")) {
- return -ERR_LENGTH_REQUIRED;
- }
- data = (char *)malloc(chunk_size);
- if (!data) {
- return -ENOMEM;
- }
- do {
- int r = s->cio->read(data, chunk_size, &read_len);
- if (r < 0) {
- free(data);
- return r;
- }
- bl.append(data, read_len);
- } while ((read_len == chunk_size));
- }
-
- free(data);
- return 0;
-}
+#define REPLICA_INPUT_MAX_LEN (512*1024)
static int parse_to_utime(string& in, utime_t& out) {
struct tm tm;
@@ -81,10 +37,11 @@ static int parse_to_utime(string& in, utime_t& out) {
return 0;
}
-static int parse_input_list(bufferlist& bl, const char *el_name, list<pair<string, utime_t> >& out) {
+static int parse_input_list(const char *data, int data_len,
+ const char *el_name, list<pair<string, utime_t> >& out) {
JSONParser parser;
- if (!parser.parse(bl.c_str(), bl.length())) {
+ if (!parser.parse(data, data_len)) {
return -EINVAL;
}
if (!parser.is_array()) {
@@ -120,19 +77,20 @@ static int parse_input_list(bufferlist& bl, const char *el_name, list<pair<strin
}
static int get_input_list(req_state *s, const char *element_name, list<pair<string, utime_t> >& out) {
- bufferlist bl;
- int rv;
+ int rv, data_len;
+ char *data;
- if ((rv = get_data(s, bl)) < 0) {
+ if ((rv = rgw_rest_read_all_input(s, &data, &data_len, REPLICA_INPUT_MAX_LEN)) < 0) {
dout(5) << "Error - reading input data - " << rv << dendl;
return rv;
}
- if ((rv = parse_input_list(bl, element_name, out)) < 0) {
+ if ((rv = parse_input_list(data, data_len, element_name, out)) < 0) {
dout(5) << "Error parsing input list - " << rv << dendl;
return rv;
}
+ free(data);
return 0;
}
diff --git a/src/rgw/rgw_rest_replica_log.h b/src/rgw/rgw_rest_replica_log.h
index 0095e6771b9..dacabbe4f7c 100644
--- a/src/rgw/rgw_rest_replica_log.h
+++ b/src/rgw/rgw_rest_replica_log.h
@@ -15,7 +15,6 @@
#define CEPH_RGW_REST_REPLICA_LOG_H
class RGWOp_OBJLog_GetBounds : public RGWRESTOp {
- int http_ret;
string prefix;
string obj_type;
utime_t oldest_time;
@@ -24,7 +23,7 @@ class RGWOp_OBJLog_GetBounds : public RGWRESTOp {
public:
RGWOp_OBJLog_GetBounds(const char *_prefix, const char *type)
- : http_ret(0) , prefix(_prefix), obj_type(type){}
+ : prefix(_prefix), obj_type(type){}
~RGWOp_OBJLog_GetBounds() {}
int check_caps(RGWUserCaps& caps) {
@@ -84,12 +83,11 @@ public:
};
class RGWOp_BILog_GetBounds : public RGWRESTOp {
- int http_ret;
utime_t oldest_time;
string lowest_bound;
list<cls_replica_log_progress_marker> entries;
public:
- RGWOp_BILog_GetBounds() : http_ret(0) {}
+ RGWOp_BILog_GetBounds() {}
~RGWOp_BILog_GetBounds() {}
int check_caps(RGWUserCaps& caps) {