From: Yan, Zheng Date: Tue, 20 Jun 2017 10:51:34 +0000 (+0800) Subject: osdc/Journaler: fix memory leak in Journaler::_issue_read() X-Git-Tag: v12.1.0~3^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15776%2Fhead;p=ceph.git osdc/Journaler: fix memory leak in Journaler::_issue_read() 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" --- diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index ba18ff5534f7..e2456c0b5768 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -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 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); } }