From: Matt Benjamin Date: Fri, 6 Jan 2017 17:30:42 +0000 (-0500) Subject: rgw_rados: add guard assert in add_io() X-Git-Tag: v12.0.0~265^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d10c37adf925d8b34daa81b419463ea376ec27aa;p=ceph-ci.git rgw_rados: add guard assert in add_io() 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 --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5ab827d7378..13afc5bc445 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -9656,7 +9656,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::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;