2
0
mirror of https://github.com/boostorg/asio.git synced 2026-02-26 02:42:08 +00:00

Fix memory leak when an io_service is allowed to destruct with unfinished

async_wait operations.


[SVN r40670]
This commit is contained in:
Christopher Kohlhoff
2007-11-01 22:42:26 +00:00
parent 2ded97148e
commit 9db4bb6bc0

View File

@@ -163,13 +163,7 @@ public:
// Destroy timers that are waiting to be cleaned up.
virtual void cleanup_timers()
{
while (cleanup_timers_)
{
timer_base* next_timer = cleanup_timers_->next_;
cleanup_timers_->next_ = 0;
cleanup_timers_->destroy();
cleanup_timers_ = next_timer;
}
destroy_timer_list(cleanup_timers_);
}
// Destroy all timers.
@@ -182,11 +176,12 @@ public:
timer_base* t = i->second;
typename hash_map<void*, timer_base*>::iterator old_i = i++;
timers_.erase(old_i);
t->destroy();
destroy_timer_list(t);
}
heap_.clear();
timers_.clear();
cleanup_timers();
destroy_timer_list(cancelled_timers_);
destroy_timer_list(cleanup_timers_);
}
private:
@@ -368,6 +363,18 @@ private:
}
}
// Destroy all timers in a linked list.
void destroy_timer_list(timer_base*& t)
{
while (t)
{
timer_base* next = t->next_;
t->next_ = 0;
t->destroy();
t = next;
}
}
// A hash of timer token to linked lists of timers.
hash_map<void*, timer_base*> timers_;