mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7129 from Elias481/fix/logrotate-segfaults-6737
avoid incrementing Ptr which could be already be in destruction-phase
This commit is contained in:
commit
ccbe9f7fbe
|
@ -110,7 +110,7 @@ void Timer::UninitializeThread()
|
||||||
void Timer::Call()
|
void Timer::Call()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
OnTimerExpired(Timer::Ptr(this));
|
OnTimerExpired(this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
InternalReschedule(true);
|
InternalReschedule(true);
|
||||||
|
|
||||||
|
@ -301,8 +301,6 @@ void Timer::TimerThreadProc()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::Ptr ptimer = timer;
|
|
||||||
|
|
||||||
/* Remove the timer from the list so it doesn't get called again
|
/* Remove the timer from the list so it doesn't get called again
|
||||||
* until the current call is completed. */
|
* until the current call is completed. */
|
||||||
l_Timers.erase(timer);
|
l_Timers.erase(timer);
|
||||||
|
@ -312,6 +310,6 @@ void Timer::TimerThreadProc()
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
/* Asynchronously call the timer. */
|
/* Asynchronously call the timer. */
|
||||||
Utility::QueueAsyncCallback(std::bind(&Timer::Call, ptimer));
|
Utility::QueueAsyncCallback(std::bind(&Timer::Call, timer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void Reschedule(double next = -1);
|
void Reschedule(double next = -1);
|
||||||
double GetNext() const;
|
double GetNext() const;
|
||||||
|
|
||||||
boost::signals2::signal<void(const Timer::Ptr&)> OnTimerExpired;
|
boost::signals2::signal<void(const Timer * const&)> OnTimerExpired;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_Interval{0}; /**< The interval of the timer. */
|
double m_Interval{0}; /**< The interval of the timer. */
|
||||||
|
|
|
@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(interval)
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
static void Callback(const Timer::Ptr&)
|
static void Callback(const Timer * const&)
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue