summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 17:55:13 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 17:55:13 +0000
commit994d493ce5db13d831abec73a859018baed178ab (patch)
treec74b659b61a0fa6218a013f817ecbc2a7dfad9f9 /net
parenta7ea883a61fc3c41addab9a6d6aa3f9f0e95b994 (diff)
downloadchromium_src-994d493ce5db13d831abec73a859018baed178ab.zip
chromium_src-994d493ce5db13d831abec73a859018baed178ab.tar.gz
chromium_src-994d493ce5db13d831abec73a859018baed178ab.tar.bz2
Fix a race condition in the unit test. The MockPending jobs actually
induce a slight delay between the time the connect is called and when the posted task can complete. We weren't waiting for the 2ms to elapse before expecting that it had completed. BUG=47836 TEST=self Review URL: http://codereview.chromium.org/2893010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/data/valgrind/net_unittests.gtest-tsan_win32.txt3
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc9
2 files changed, 8 insertions, 4 deletions
diff --git a/net/data/valgrind/net_unittests.gtest-tsan_win32.txt b/net/data/valgrind/net_unittests.gtest-tsan_win32.txt
index 0fc6d3c..9994b31 100644
--- a/net/data/valgrind/net_unittests.gtest-tsan_win32.txt
+++ b/net/data/valgrind/net_unittests.gtest-tsan_win32.txt
@@ -11,9 +11,6 @@ URLRequestTest.QuitTest
# See http://crbug.com/46647
DiskCacheBackendTest.*
-# See http://crbug.com/47836
-ClientSocketPoolBaseTest.CancelPendingSocketAtSocketLimit
-
#########################################
# These tests fail if you don't have our SSL certificate installed.
# Please see http://dev.chromium.org/developers/testing#TOC-SSL-tests
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index a936c8b..03c7879 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -117,6 +117,10 @@ class TestConnectJob : public ConnectJob {
kMockAdvancingLoadStateJob,
};
+ // The kMockPendingJob uses a slight delay before allowing the connect
+ // to complete.
+ static const int kPendingConnectDelay = 2;
+
TestConnectJob(JobType job_type,
const std::string& group_name,
const TestClientSocketPoolBase::Request& request,
@@ -169,7 +173,7 @@ class TestConnectJob : public ConnectJob {
&TestConnectJob::DoConnect,
true /* successful */,
true /* async */),
- 2);
+ kPendingConnectDelay);
return ERR_IO_PENDING;
case kMockPendingFailingJob:
set_load_state(LOAD_STATE_CONNECTING);
@@ -884,6 +888,9 @@ TEST_F(ClientSocketPoolBaseTest, CancelPendingSocketAtSocketLimit) {
// Cancel the stalled request.
handles[0].Reset();
+ // Wait for the pending job to be guaranteed to complete.
+ PlatformThread::Sleep(TestConnectJob::kPendingConnectDelay * 2);
+
MessageLoop::current()->RunAllPending();
// Now we should have a connect job.