From 91ae593110ffa5cd85c8fe61181fbbe658c29b9a Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 4 Jul 2019 20:35:09 +0200 Subject: [PATCH] Fixed crash in server --- src/EventLoop.cpp | 9 +++++++-- src/misc/timer.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/EventLoop.cpp b/src/EventLoop.cpp index 890ebba..046db2b 100644 --- a/src/EventLoop.cpp +++ b/src/EventLoop.cpp @@ -204,12 +204,17 @@ void EventExecutor::_executor(ts::event::EventExecutor *loop) { } auto event_handler = linked_entry->entry.lock(); + if(!event_handler) { + /* event handler passed away while waiting for beeing executed */ + delete linked_entry; + continue; + } + sassert(event_handler->_event_ptr == linked_entry); event_handler->_event_ptr = nullptr; lock.unlock(); - if(event_handler) - event_handler->event_execute(linked_entry->scheduled); + event_handler->event_execute(linked_entry->scheduled); delete linked_entry; } } \ No newline at end of file diff --git a/src/misc/timer.h b/src/misc/timer.h index 334f4a3..6bcf5f1 100644 --- a/src/misc/timer.h +++ b/src/misc/timer.h @@ -33,4 +33,5 @@ name ##_timings.timings.push_back({step, std::chrono::system_clock::now()}); tp = entry.ts; \ } \ return result; \ -})() \ No newline at end of file +})() +/* FIX the "backslash-newline at end of file" warning */ \ No newline at end of file