]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix for duplicates in list_periods() 9047/head
authorCasey Bodley <cbodley@redhat.com>
Fri, 6 May 2016 19:57:22 +0000 (15:57 -0400)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 May 2016 16:49:46 +0000 (09:49 -0700)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit abed30befd86c68922759a66db589285fe01e54b)

src/rgw/rgw_rados.cc

index 021efba8d212dfcaaecaf8ce1ac00333ab2b8dbd..a443cc13b8418c86ca7d8d50bf84418886ea10f0 100644 (file)
@@ -3826,14 +3826,15 @@ int RGWRados::list_periods(list<string>& periods)
   if (ret < 0) {
     return ret;
   }
-  for(list<string>::iterator iter = raw_periods.begin(); iter != raw_periods.end(); iter++) {
-    size_t pos = iter->find(".");
-    if ( pos != std::string::npos) {
-      periods.push_back(iter->substr(0, pos));
+  for (const auto& oid : raw_periods) {
+    size_t pos = oid.find(".");
+    if (pos != std::string::npos) {
+      periods.push_back(oid.substr(0, pos));
     } else {
-      periods.push_back(*iter);
+      periods.push_back(oid);
     }
   }
+  periods.sort(); // unique() only detects duplicates if they're adjacent
   periods.unique();
   return 0;
 }