mirror of https://github.com/Icinga/icinga2.git
Fixed weak ptr deref bug.
This commit is contained in:
parent
5ae2c4aa5b
commit
90c4d6624b
|
@ -59,11 +59,17 @@ void Application::RunEventLoop(void)
|
||||||
FD_ZERO(&writefds);
|
FD_ZERO(&writefds);
|
||||||
FD_ZERO(&exceptfds);
|
FD_ZERO(&exceptfds);
|
||||||
|
|
||||||
for (Socket::CollectionType::iterator i = Socket::Sockets.begin(); i != Socket::Sockets.end(); i++) {
|
Socket::CollectionType::iterator prev, i;
|
||||||
|
for (i = Socket::Sockets.begin(); i != Socket::Sockets.end(); ) {
|
||||||
Socket::Ptr socket = i->lock();
|
Socket::Ptr socket = i->lock();
|
||||||
|
|
||||||
if (socket == NULL)
|
prev = i;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (!socket) {
|
||||||
|
Socket::Sockets.erase(prev);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int fd = socket->GetFD();
|
int fd = socket->GetFD();
|
||||||
|
|
||||||
|
@ -106,15 +112,16 @@ void Application::RunEventLoop(void)
|
||||||
EventArgs ea;
|
EventArgs ea;
|
||||||
ea.Source = shared_from_this();
|
ea.Source = shared_from_this();
|
||||||
|
|
||||||
Socket::CollectionType::iterator prev, i;
|
|
||||||
for (i = Socket::Sockets.begin(); i != Socket::Sockets.end(); ) {
|
for (i = Socket::Sockets.begin(); i != Socket::Sockets.end(); ) {
|
||||||
|
Socket::Ptr socket = i->lock();
|
||||||
|
|
||||||
prev = i;
|
prev = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
Socket::Ptr socket = prev->lock();
|
if (!socket) {
|
||||||
|
Socket::Sockets.erase(prev);
|
||||||
if (socket == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int fd = socket->GetFD();
|
int fd = socket->GetFD();
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,17 @@ void Timer::CallExpiredTimers(void)
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
for (Timer::CollectionType::iterator i = Timers.begin(); i != Timers.end(); ) {
|
Timer::CollectionType::iterator prev, i;
|
||||||
Timer::Ptr timer = Timer::Ptr(*i);
|
for (i = Timers.begin(); i != Timers.end(); ) {
|
||||||
|
Timer::Ptr timer = i->lock();
|
||||||
|
|
||||||
|
prev = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (timer == NULL)
|
if (!timer) {
|
||||||
|
Timers.erase(prev);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (timer->m_Next <= now) {
|
if (timer->m_Next <= now) {
|
||||||
timer->Call();
|
timer->Call();
|
||||||
|
|
Loading…
Reference in New Issue