]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_rados: add guard assert in add_io()
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 6 Jan 2017 17:30:42 +0000 (12:30 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 13 Jan 2017 17:08:56 +0000 (12:08 -0500)
Use the iterator-returning insert operation in std::map, check
assert the insert case.  As a side effect, this makes use of the
inserted object record more clear.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit d10c37adf925d8b34daa81b419463ea376ec27aa)

src/rgw/rgw_rados.cc

index 0d03cb951286c289eb257878fcdef817caf02e30..c971d345d6cf4be9bf29750456352137ab4a15f9 100644 (file)
@@ -9655,7 +9655,12 @@ struct get_obj_data : public RefCountedObject {
   void add_io(off_t ofs, off_t len, bufferlist **pbl, AioCompletion **pc) {
     Mutex::Locker l(lock);
 
-    get_obj_io& io = io_map[ofs];
+    const auto& io_iter = io_map.insert(
+      map<off_t, get_obj_io>::value_type(ofs, get_obj_io()));
+
+    assert(io_iter.second); // assert new insertion
+
+    get_obj_io& io = (io_iter.first)->second;
     *pbl = &io.bl;
 
     struct get_obj_aio_data aio;