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

Side by Side Diff: net/socket/client_socket_pool_base_unittest.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, 6 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 unified diff | Download patch
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/platform_thread.h" 10 #include "base/platform_thread.h"
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 // Before the DoReleaseSocket() task has run, start up a 1625 // Before the DoReleaseSocket() task has run, start up a
1626 // TestReleasingSocketRequest. This one will be ERR_IO_PENDING since 1626 // TestReleasingSocketRequest. This one will be ERR_IO_PENDING since
1627 // num_releasing_sockets > 0 and there was no idle socket to use yet. 1627 // num_releasing_sockets > 0 and there was no idle socket to use yet.
1628 TestReleasingSocketRequest request(pool_.get()); 1628 TestReleasingSocketRequest request(pool_.get());
1629 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority, 1629 EXPECT_EQ(ERR_IO_PENDING, InitHandle(request.handle(), "a", kDefaultPriority,
1630 &request, pool_, BoundNetLog())); 1630 &request, pool_, BoundNetLog()));
1631 1631
1632 EXPECT_EQ(OK, request.WaitForResult()); 1632 EXPECT_EQ(OK, request.WaitForResult());
1633 } 1633 }
1634 1634
1635 // http://crbug.com/44724 regression test.
1636 // We start releasing the pool when we flush on network change. When that
1637 // happens, the only active references are in the ClientSocketHandles. When a
1638 // ConnectJob completes and calls back into the last ClientSocketHandle, that
1639 // callback can release the last reference and delete the pool. After the
1640 // callback finishes, we go back to the stack frame within the now-deleted pool.
1641 // Executing any code that refers to members of the now-deleted pool can cause
1642 // crashes.
1643 TEST_F(ClientSocketPoolBaseTest, CallbackThatReleasesPool) {
1644 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1645 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1646
1647 ClientSocketHandle handle;
1648 TestCompletionCallback callback;
1649 EXPECT_EQ(ERR_IO_PENDING,
1650 InitHandle(&handle, "a", kDefaultPriority,
1651 &callback, pool_, BoundNetLog()));
1652
1653 // Simulate flushing the pool.
1654 pool_ = NULL;
1655
1656 // We'll call back into this now.
1657 callback.WaitForResult();
1658 }
1659
1635 } // namespace 1660 } // namespace
1636 1661
1637 } // namespace net 1662 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698