OLD | NEW |
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 Loading... |
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 |
OLD | NEW |