diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 18:22:24 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 18:22:24 +0000 |
commit | a7e38577aab81d13d9fc1dff5a8b6fe164ed2102 (patch) | |
tree | 03c3e30bd44f33a4317bbe5606f9c0e40c27ce40 /net/socket/client_socket_pool_base.h | |
parent | b846acde84543772099763542d9411eacbe684f9 (diff) | |
download | chromium_src-a7e38577aab81d13d9fc1dff5a8b6fe164ed2102.zip chromium_src-a7e38577aab81d13d9fc1dff5a8b6fe164ed2102.tar.gz chromium_src-a7e38577aab81d13d9fc1dff5a8b6fe164ed2102.tar.bz2 |
Do not attempt to reuse active sockets after a socket pool flush (usually a network change).
Implements this functionality by adding an |id_| field to ClientSocketPoolBaseHelper that is incremented on each Flush().
BUG=45872
Review URL: http://codereview.chromium.org/2647003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base.h')
-rw-r--r-- | net/socket/client_socket_pool_base.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index 470c120..a037b0e 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -188,8 +188,12 @@ class ClientSocketPoolBaseHelper // See ClientSocketPool::ReleaseSocket for documentation on this function. void ReleaseSocket(const std::string& group_name, - ClientSocket* socket); + ClientSocket* socket, + int id); + // See ClientSocketPool::Flush for documentation on this function. + void Flush(); + // See ClientSocketPool::CloseIdleSockets for documentation on this function. void CloseIdleSockets(); @@ -216,7 +220,7 @@ class ClientSocketPoolBaseHelper virtual void OnConnectJobComplete(int result, ConnectJob* job); // NetworkChangeNotifier::Observer methods: - virtual void OnIPAddressChanged(); + virtual void OnIPAddressChanged() { Flush(); } // For testing. bool may_have_stalled_group() const { return may_have_stalled_group_; } @@ -335,7 +339,8 @@ class ClientSocketPoolBaseHelper void DecrementIdleCount(); // Called via PostTask by ReleaseSocket. - void DoReleaseSocket(const std::string& group_name, ClientSocket* socket); + void DoReleaseSocket( + const std::string& group_name, ClientSocket* socket, int id); // Scans the group map for groups which have an available socket slot and // at least one pending request. Returns number of groups found, and if found @@ -451,6 +456,11 @@ class ClientSocketPoolBaseHelper // A factory to pin the backup_job tasks. ScopedRunnableMethodFactory<ClientSocketPoolBaseHelper> method_factory_; + + // A unique id for the pool. It gets incremented every time we Flush() the + // pool. This is so that when sockets get released back to the pool, we can + // make sure that they are discarded rather than reused. + int pool_generation_number_; }; } // namespace internal @@ -542,8 +552,8 @@ class ClientSocketPoolBase { return helper_->CancelRequest(group_name, handle); } - void ReleaseSocket(const std::string& group_name, ClientSocket* socket) { - return helper_->ReleaseSocket(group_name, socket); + void ReleaseSocket(const std::string& group_name, ClientSocket* socket, int id) { + return helper_->ReleaseSocket(group_name, socket, id); } void CloseIdleSockets() { return helper_->CloseIdleSockets(); } @@ -586,6 +596,8 @@ class ClientSocketPoolBase { void enable_backup_jobs() { helper_->enable_backup_jobs(); } + void Flush() { helper_->Flush(); } + private: // This adaptor class exists to bridge the // internal::ClientSocketPoolBaseHelper::ConnectJobFactory and |