]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/ObjectCacher: refresh iterator in read apply loop
authorSage Weil <sage@inktank.com>
Wed, 24 Oct 2012 19:48:02 +0000 (12:48 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Oct 2012 18:31:45 +0000 (11:31 -0700)
The p iterator points to the next bh, but try_merge_bh() at the end of the
loop might merge that into our result and invalidate the iterator.  Fix
this by repeating the lookup on each pass through the loop.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osdc/ObjectCacher.cc

index 803bb4c652d6e57d082ec184bd15a2514e87b07a..218d9dbd2f963bf35576f53266909717aaff2f9a 100644 (file)
@@ -564,10 +564,13 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, loff_t start,
     
     // apply to bh's!
     loff_t opos = start;
-    map<loff_t, BufferHead*>::iterator p = ob->data.lower_bound(opos);
-    
-    while (p != ob->data.end() &&
-           opos < start+(loff_t)length) {
+    while (true) {
+      map<loff_t, BufferHead*>::iterator p = ob->data.lower_bound(opos);
+      if (p == ob->data.end())
+       break;
+      if (opos >= start+(loff_t)length)
+       break;
+
       BufferHead *bh = p->second;
       
       if (bh->start() > opos) {