]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Journaler: fix memory leak in Journaler::_issue_read() 15776/head
authorYan, Zheng <zyan@redhat.com>
Tue, 20 Jun 2017 10:51:34 +0000 (18:51 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 20 Jun 2017 11:00:38 +0000 (19:00 +0800)
Contexts executed by _finish_flush() may call _issue_read(),
_issue_read() may add new context to tail of waitfor_safe list.
So _finish_flush() should first remove contexts from waitfor_safe,
then execute the contexts.

Fixes: http://tracker.ceph.com/issues/20338
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/osdc/Journaler.cc

index ba18ff5534f7e85abd88e26ea9fc807d26e83fc8..e2456c0b57688366a7d3fe1f700554f231fb4db2 100644 (file)
@@ -526,11 +526,16 @@ void Journaler::_finish_flush(int r, uint64_t start, ceph::real_time stamp)
                 << dendl;
 
   // kick waiters <= safe_pos
-  while (!waitfor_safe.empty()) {
-    if (waitfor_safe.begin()->first > safe_pos)
-      break;
-    finish_contexts(cct, waitfor_safe.begin()->second);
-    waitfor_safe.erase(waitfor_safe.begin());
+  if (!waitfor_safe.empty()) {
+    list<Context*> ls;
+    while (!waitfor_safe.empty()) {
+      auto it = waitfor_safe.begin();
+      if (it->first > safe_pos)
+       break;
+      ls.splice(ls.end(), it->second);
+      waitfor_safe.erase(it);
+    }
+    finish_contexts(cct, ls);
   }
 }