]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/filestore: do not free event not added
authorKefu Chai <kchai@redhat.com>
Mon, 10 Jul 2017 07:31:43 +0000 (15:31 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 10 Jul 2017 07:45:10 +0000 (15:45 +0800)
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 <kchai@redhat.com>
src/os/filestore/FileStore.cc

index 12adbcdb9f21e009633fb591939a590c9cd2bb9c..8a3a5a1db9f61aa11c198e3b4bac50bae09f3e88 100644 (file)
@@ -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();
     }