]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix requeue_ops
authorSage Weil <sage.weil@dreamhost.com>
Thu, 20 Oct 2011 21:11:20 +0000 (14:11 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Thu, 20 Oct 2011 21:12:20 +0000 (14:12 -0700)
The ls argument passed to requeue_ops() is a reference, and one of the
methods we call (say, _handle_op) might want to requeue the message on the
same list we were passed, leading to an infinite loop.

Set ls contents aside to avoid that.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/OSD.cc

index b889a717dac711fc963ecbc4405a4c927b4d4480..63690117eb08d67df9929dfc3672c0d0d438bd57 100644 (file)
@@ -5334,10 +5334,15 @@ void OSD::requeue_ops(PG *pg, list<Message*>& ls)
   list<Message*> orig_queue;
   orig_queue.swap(pg->op_queue);
 
+  // grab whole list at once, in case methods we call below start adding things
+  // back on the list reference we were passed!
+  list<Message*> q;
+  q.swap(ls);
+
   // requeue old items, now at front.
-  while (!ls.empty()) {
-    Message *op = ls.front();
-    ls.pop_front();
+  while (!q.empty()) {
+    Message *op = q.front();
+    q.pop_front();
 
     switch (op->get_type()) {
     case CEPH_MSG_OSD_OP: