You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2016/07/01 17:13:01 UTC
[trafficserver] branch master updated: TS-4629: Fix use of invalid
iterator in ServerSessionPool::purge. Add postfix increment to
IPHashTable::iterator. This closes #780.
This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 44bc6b9 TS-4629: Fix use of invalid iterator in ServerSessionPool::purge. Add postfix increment to IPHashTable::iterator. This closes #780.
44bc6b9 is described below
commit 44bc6b9e072580558ac391454c80809f8aa8e4d0
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Fri Jul 1 11:36:36 2016 -0500
TS-4629: Fix use of invalid iterator in ServerSessionPool::purge.
Add postfix increment to IPHashTable::iterator.
This closes #780.
---
lib/ts/Map.h | 10 +++++++++-
proxy/http/HttpSessionManager.cc | 7 ++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/lib/ts/Map.h b/lib/ts/Map.h
index fb8b5d0..3140323 100644
--- a/lib/ts/Map.h
+++ b/lib/ts/Map.h
@@ -1306,7 +1306,7 @@ public:
/** 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 @@ public:
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 H> typename TSHashTable<H>::iterator &TSHashTable<H>::iterato
return *this;
}
+template <typename H> typename TSHashTable<H>::iterator TSHashTable<H>::iterator::operator++(int)
+{
+ iterator prev(*this);
+ ++*this;
+ return prev;
+}
+
template <typename H>
TSHashTable<H>::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 f5a474b..700e8ac 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();
}
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].