From: Kefu Chai Date: Mon, 10 Jul 2017 07:31:43 +0000 (+0800) Subject: os/filestore: do not free event not added X-Git-Tag: v12.1.1~89^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F16235%2Fhead;p=ceph.git 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 --- 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(); }