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

Unified Diff: net/socket/client_socket_pool_base.cc

Issue 2250001: Fixes an invalid read bug in ClientSocketPoolBaseHelper and cancels ConnectJobs on network changes. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Redo. 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 | « no previous file | net/socket/client_socket_pool_base_unittest.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.cc
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 99011bed65aa8e7b70ce60879d7f7ee8ea7c5ab0..31bec818325a56abc88d07f67e38193d5e844e9b 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -332,6 +332,10 @@ void ClientSocketPoolBaseHelper::OnBackupSocketTimerFired(
void ClientSocketPoolBaseHelper::CancelRequest(
const std::string& group_name, const ClientSocketHandle* handle) {
+ // Running callbacks can cause the last outside reference to be released.
+ // Hold onto a reference.
+ scoped_refptr<ClientSocketPoolBaseHelper> ref_holder(this);
+
CHECK(ContainsKey(group_map_, group_name));
Group& group = group_map_[group_name];
@@ -470,6 +474,10 @@ void ClientSocketPoolBaseHelper::DecrementIdleCount() {
void ClientSocketPoolBaseHelper::DoReleaseSocket(const std::string& group_name,
ClientSocket* socket) {
+ // Running callbacks can cause the last outside reference to be released.
+ // Hold onto a reference.
+ scoped_refptr<ClientSocketPoolBaseHelper> ref_holder(this);
+
GroupMap::iterator i = group_map_.find(group_name);
CHECK(i != group_map_.end());
@@ -563,6 +571,10 @@ int ClientSocketPoolBaseHelper::FindTopStalledGroup(Group** group,
void ClientSocketPoolBaseHelper::OnConnectJobComplete(
int result, ConnectJob* job) {
+ // Running callbacks can cause the last outside reference to be released.
+ // Hold onto a reference.
+ scoped_refptr<ClientSocketPoolBaseHelper> ref_holder(this);
+
DCHECK_NE(ERR_IO_PENDING, result);
const std::string group_name = job->group_name();
GroupMap::iterator group_it = group_map_.find(group_name);
@@ -611,6 +623,7 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
}
void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
+ CancelAllConnectJobs();
CloseIdleSockets();
}
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698