do {
RGWUserBuckets buckets;
uint64_t read_count;
- if (limit > 0)
+ if (limit >= 0) {
read_count = min(limit - total_count, (uint64_t)max_buckets);
- else
+ } else {
read_count = max_buckets;
+ }
ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
- marker, read_count, should_get_stats());
+ marker, read_count, should_get_stats(), 0);
- if (!started) {
- send_response_begin(buckets.count() > 0);
- started = true;
- }
-
if (ret < 0) {
/* hmm.. something wrong here.. the user was authenticated, so it
should exist */
marker = iter->first;
}
buckets_count += m.size();
-
total_count += m.size();
- done = (m.size() < read_count || (limit > 0 && total_count == limit));
+ done = (m.size() < read_count || (limit >= 0 && total_count >= (uint64_t)limit));
+ if (!started) {
+ send_response_begin(buckets.count() > 0);
+ started = true;
+ }
+
if (!m.empty()) {
send_response_data(buckets);
int RGWListBuckets_ObjStore_SWIFT::get_params()
{
marker = s->info.args.get("marker");
- string limit_str;
- limit_str = s->info.args.get("limit");
- long l = strtol(limit_str.c_str(), NULL, 10);
- if (l > (long)limit_max || l < 0)
- return -ERR_PRECONDITION_FAILED;
- limit = (uint64_t)l;
+ string limit_str = s->info.args.get("limit");
+ if (!limit_str.empty()) {
+ string err;
+ long l = strict_strtol(limit_str.c_str(), 10, &err);
+ if (!err.empty()) {
+ return -EINVAL;
+ }
- if (limit == 0)
- limit = limit_max;
+ if (l > (long)limit_max || l < 0) {
+ return -EINVAL;
+ }
+
+ limit = (uint64_t)l;
+ }
- need_stats = (s->format != RGW_FORMAT_PLAIN);
-
if (need_stats) {
bool stats, exists;
int r = s->info.args.get_bool("stats", &stats, &exists);