Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: net/socket/client_socket_pool_base.h

Issue 2647003: Do not attempt to reuse active sockets after a socket pool flush (usually a network change). (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Address eroman comments. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/client_socket_pool.h ('k') | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base.h
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 470c120ed618401f82346822c330dfe55b20b1e9..a037b0e2a0783b40ff0c11b62bc0758b9a304f2a 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
« no previous file with comments | « net/socket/client_socket_pool.h ('k') | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698