From 2bdb6627bfb1937cbc704286e272a312f93b8bc6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 10 Jul 2017 15:31:43 +0800 Subject: [PATCH] os/filestore: do not free event not added if an event fails to be added, it's freed by the callee. so we should not try to free it again. that address could be re-used by the allocator, to we might be freeing an irrelevent event. Signed-off-by: Kefu Chai --- src/os/filestore/FileStore.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 12adbcdb9f2..8a3a5a1db9f 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -3984,7 +3984,10 @@ void FileStore::sync_entry() sync_entry_timeo_lock.Lock(); SyncEntryTimeout *sync_entry_timeo = new SyncEntryTimeout(cct, m_filestore_commit_timeout); - timer.add_event_after(m_filestore_commit_timeout, sync_entry_timeo); + if (!timer.add_event_after(m_filestore_commit_timeout, + sync_entry_timeo)) { + sync_entry_timeo = nullptr; + } sync_entry_timeo_lock.Unlock(); logger->set(l_filestore_committing, 1); @@ -4091,9 +4094,10 @@ void FileStore::sync_entry() dout(15) << __FUNC__ << ": committed to op_seq " << cp << dendl; - sync_entry_timeo_lock.Lock(); - timer.cancel_event(sync_entry_timeo); - sync_entry_timeo_lock.Unlock(); + if (sync_entry_timeo) { + Mutex::Locker lock(sync_entry_timeo_lock); + timer.cancel_event(sync_entry_timeo); + } } else { op_tp.unpause(); } -- 2.39.5