diff --git a/lib/ts/Map.h b/lib/ts/Map.h index fb8b5d0f44a..3140323f0fa 100644 --- a/lib/ts/Map.h +++ b/lib/ts/Map.h @@ -1306,7 +1306,7 @@ class TSHashTable /** Standard iterator for walking the table. This iterates over all elements. - @internal Iterator is end if m_value is NULL. + @internal Iterator is @a end if @a m_value is @c NULL. */ struct iterator { Value *m_value; ///< Current location. @@ -1314,6 +1314,7 @@ class TSHashTable iterator() : m_value(0), m_bucket(0) {} iterator &operator++(); + iterator operator++(int); Value &operator*() { return *m_value; } Value *operator->() { return m_value; } bool @@ -1495,6 +1496,13 @@ template typename TSHashTable::iterator &TSHashTable::iterato return *this; } +template typename TSHashTable::iterator TSHashTable::iterator::operator++(int) +{ + iterator prev(*this); + ++*this; + return prev; +} + template TSHashTable::TSHashTable(size_t nb) : m_count(0), m_expansion_policy(AVERAGE), m_expansion_limit(DEFAULT_EXPANSION_LIMIT) { diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index f5a474bbab9..1145f3029cd 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -55,9 +55,10 @@ ServerSessionPool::ServerSessionPool() : Continuation(new_ProxyMutex()), m_ip_po void ServerSessionPool::purge() { - for (IPHashTable::iterator last = m_ip_pool.end(), spot = m_ip_pool.begin(); spot != last; ++spot) { - spot->do_io_close(); - } + // @c do_io_close can free the instance which clears the intrusive links and breaks the iterator. + // Therefore @c do_io_close is called on a post-incremented iterator. + for (IPHashTable::iterator last = m_ip_pool.end(), spot = m_ip_pool.begin(); spot != last ; spot++->do_io_close()) + ; // empty m_ip_pool.clear(); m_host_pool.clear(); }