summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_pool_base_unittest.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-25 17:49:51 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-25 17:49:51 +0000
commit2abfe90a9461dfa9a8b1252a94e464e46864ca35 (patch)
treed7bab53d05e1ae8cdd4dfaad076a72f14424ed34 /net/socket/client_socket_pool_base_unittest.cc
parent19fbd619f3ce5562ed34ce0fea80250a2a296b19 (diff)
downloadchromium_src-2abfe90a9461dfa9a8b1252a94e464e46864ca35.zip
chromium_src-2abfe90a9461dfa9a8b1252a94e464e46864ca35.tar.gz
chromium_src-2abfe90a9461dfa9a8b1252a94e464e46864ca35.tar.bz2
Fix a crash in ClientSocketPoolBaseHelper where we double erase a Group from the GroupMap.
BUG=49254 Review URL: http://codereview.chromium.org/3104026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57346 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base_unittest.cc')
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc40
1 files changed, 39 insertions, 1 deletions
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index d8ea1d9..89db61d 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -420,6 +420,10 @@ class TestClientSocketPool : public ClientSocketPool {
return base_.NumConnectJobsInGroup(group_name);
}
+ bool HasGroup(const std::string& group_name) const {
+ return base_.HasGroup(group_name);
+ }
+
void CleanupTimedOutIdleSockets() { base_.CleanupIdleSockets(false); }
void EnableConnectBackupJobs() { base_.EnableConnectBackupJobs(); }
@@ -2057,7 +2061,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtGroupCapacity) {
// Test out the case where we have one socket connected, one
// connecting, when the first socket finishes and goes idle.
-// Although the second connection is pending, th second request
+// Although the second connection is pending, the second request
// should complete, by taking the first socket's idle socket.
TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtStall) {
CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
@@ -2105,6 +2109,40 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtStall) {
MessageLoop::current()->RunAllPending();
}
+// Cover the case where on an available socket slot, we have one pending
+// request that completes synchronously, thereby making the Group empty.
+TEST_F(ClientSocketPoolBaseTest, SynchronouslyProcessOnePendingRequest) {
+ const int kUnlimitedSockets = 100;
+ const int kOneSocketPerGroup = 1;
+ CreatePool(kUnlimitedSockets, kOneSocketPerGroup);
+
+ // Make the first request asynchronous fail.
+ // This will free up a socket slot later.
+ connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
+
+ ClientSocketHandle handle1;
+ TestCompletionCallback callback1;
+ EXPECT_EQ(ERR_IO_PENDING, handle1.Init("a", params_, kDefaultPriority,
+ &callback1, pool_, BoundNetLog()));
+ EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a"));
+
+ // Make the second request synchronously fail. This should make the Group
+ // empty.
+ connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob);
+ ClientSocketHandle handle2;
+ TestCompletionCallback callback2;
+ // It'll be ERR_IO_PENDING now, but the TestConnectJob will synchronously fail
+ // when created.
+ EXPECT_EQ(ERR_IO_PENDING, handle2.Init("a", params_, kDefaultPriority,
+ &callback2, pool_, BoundNetLog()));
+
+ EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a"));
+
+ EXPECT_EQ(ERR_CONNECTION_FAILED, callback1.WaitForResult());
+ EXPECT_EQ(ERR_CONNECTION_FAILED, callback2.WaitForResult());
+ EXPECT_FALSE(pool_->HasGroup("a"));
+}
+
} // namespace
} // namespace net