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

Side by Side Diff: net/socket/client_socket_pool_base_unittest.cc

Issue 2888623011: Fix for HTTP2 request hanging bug. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 ASSERT_LE(kNumberOfRequests, kMaxSockets); // Otherwise the test will hang. 1682 ASSERT_LE(kNumberOfRequests, kMaxSockets); // Otherwise the test will hang.
1683 1683
1684 // Queue up all the requests 1684 // Queue up all the requests
1685 for (size_t i = 0; i < kNumberOfRequests; ++i) 1685 for (size_t i = 0; i < kNumberOfRequests; ++i)
1686 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING)); 1686 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING));
1687 1687
1688 for (size_t i = 0; i < kNumberOfRequests; ++i) 1688 for (size_t i = 0; i < kNumberOfRequests; ++i)
1689 EXPECT_THAT(request(i)->WaitForResult(), IsError(ERR_CONNECTION_FAILED)); 1689 EXPECT_THAT(request(i)->WaitForResult(), IsError(ERR_CONNECTION_FAILED));
1690 } 1690 }
1691 1691
1692 // Make sure that pending requests that complete synchronously get serviced
1693 // after active requests fail. See https://crbug.com/723748
1694 TEST_F(ClientSocketPoolBaseTest, HandleMultipleSyncFailuresAfterAsyncFailure) {
1695 const size_t kNumberOfRequests = 10;
1696 const size_t kMaxSockets = 1;
1697 CreatePool(kMaxSockets, kMaxSockets);
1698
1699 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingFailingJob);
1700
1701 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING));
1702
1703 connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob);
1704
1705 // Queue up all the other requests
1706 for (size_t i = 1; i < kNumberOfRequests; ++i)
1707 EXPECT_THAT(StartRequest("a", DEFAULT_PRIORITY), IsError(ERR_IO_PENDING));
1708
1709 // Make sure all requests fail, instead of hanging.
1710 for (size_t i = 0; i < kNumberOfRequests; ++i)
1711 EXPECT_THAT(request(i)->WaitForResult(), IsError(ERR_CONNECTION_FAILED));
1712 }
1713
1692 TEST_F(ClientSocketPoolBaseTest, CancelActiveRequestThenRequestSocket) { 1714 TEST_F(ClientSocketPoolBaseTest, CancelActiveRequestThenRequestSocket) {
1693 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); 1715 CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup);
1694 1716
1695 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); 1717 connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
1696 1718
1697 ClientSocketHandle handle; 1719 ClientSocketHandle handle;
1698 TestCompletionCallback callback; 1720 TestCompletionCallback callback;
1699 int rv = handle.Init("a", params_, DEFAULT_PRIORITY, 1721 int rv = handle.Init("a", params_, DEFAULT_PRIORITY,
1700 ClientSocketPool::RespectLimits::ENABLED, 1722 ClientSocketPool::RespectLimits::ENABLED,
1701 callback.callback(), pool_.get(), NetLogWithSource()); 1723 callback.callback(), pool_.get(), NetLogWithSource());
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
4075 request(1)->handle()->Reset(); 4097 request(1)->handle()->Reset();
4076 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); 4098 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a"));
4077 4099
4078 EXPECT_THAT(request(2)->WaitForResult(), IsOk()); 4100 EXPECT_THAT(request(2)->WaitForResult(), IsOk());
4079 EXPECT_FALSE(request(1)->have_result()); 4101 EXPECT_FALSE(request(1)->have_result());
4080 } 4102 }
4081 4103
4082 } // namespace 4104 } // namespace
4083 4105
4084 } // namespace net 4106 } // namespace net
OLDNEW
« net/socket/client_socket_pool_base.cc ('K') | « 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