OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 <dirent.h> | 5 #include <dirent.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 return number_of_open_fds; | 33 return number_of_open_fds; |
34 } | 34 } |
35 | 35 |
36 // Creates a new QuicClient and Initializes it. Caller is responsible for | 36 // Creates a new QuicClient and Initializes it. Caller is responsible for |
37 // deletion. | 37 // deletion. |
38 QuicClient* CreateAndInitializeQuicClient(EpollServer* eps, uint16 port) { | 38 QuicClient* CreateAndInitializeQuicClient(EpollServer* eps, uint16 port) { |
39 IPEndPoint server_address(IPEndPoint(net::test::Loopback4(), port)); | 39 IPEndPoint server_address(IPEndPoint(net::test::Loopback4(), port)); |
40 QuicServerId server_id("hostname", server_address.port(), false, | 40 QuicServerId server_id("hostname", server_address.port(), false, |
41 PRIVACY_MODE_DISABLED); | 41 PRIVACY_MODE_DISABLED); |
42 QuicVersionVector versions = QuicSupportedVersions(); | 42 QuicVersionVector versions = QuicSupportedVersions(); |
43 QuicClient* client = | 43 QuicClient* client = new QuicClient(server_address, server_id, versions, eps); |
44 new QuicClient(server_address, server_id, versions, false, eps); | |
45 EXPECT_TRUE(client->Initialize()); | 44 EXPECT_TRUE(client->Initialize()); |
46 return client; | 45 return client; |
47 } | 46 } |
48 | 47 |
49 TEST(QuicClientTest, DoNotLeakFDs) { | 48 TEST(QuicClientTest, DoNotLeakFDs) { |
50 // Make sure that the QuicClient doesn't leak FDs. Doing so could cause port | 49 // Make sure that the QuicClient doesn't leak FDs. Doing so could cause port |
51 // exhaustion in long running processes which repeatedly create clients. | 50 // exhaustion in long running processes which repeatedly create clients. |
52 | 51 |
53 // Record initial number of FDs, after creation of EpollServer. | 52 // Record initial number of FDs, after creation of EpollServer. |
54 EpollServer eps; | 53 EpollServer eps; |
(...skipping 11 matching lines...) Expand all Loading... |
66 } | 65 } |
67 | 66 |
68 // The FDs created by the QuicClients should now be closed. | 67 // The FDs created by the QuicClients should now be closed. |
69 EXPECT_EQ(number_of_open_fds, NumOpenFDs()); | 68 EXPECT_EQ(number_of_open_fds, NumOpenFDs()); |
70 } | 69 } |
71 | 70 |
72 } // namespace | 71 } // namespace |
73 } // namespace test | 72 } // namespace test |
74 } // namespace tools | 73 } // namespace tools |
75 } // namespace net | 74 } // namespace net |
OLD | NEW |