Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/net/ServerSocket/AnotherSelectFdsLimit.java
41152 views
1
/*
2
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 8035897
27
* @summary FD_SETSIZE should be set on macosx
28
* @run main/othervm AnotherSelectFdsLimit 1023
29
* @run main/othervm AnotherSelectFdsLimit 1024
30
* @run main/othervm AnotherSelectFdsLimit 1025
31
* @run main/othervm AnotherSelectFdsLimit 1600
32
*/
33
34
import java.io.IOException;
35
import java.net.ServerSocket;
36
import java.net.SocketTimeoutException;
37
import java.util.ArrayList;
38
import java.util.List;
39
40
public class AnotherSelectFdsLimit {
41
static final int DEFAULT_FDS_TO_USE = 1600;
42
43
public static void main(String [] args) throws Exception {
44
if (!System.getProperty("os.name").contains("OS X")) {
45
System.out.println("Test only run on MAC. Exiting.");
46
return;
47
}
48
49
int fdsToUse = DEFAULT_FDS_TO_USE;
50
if (args.length == 1)
51
fdsToUse = Integer.parseInt(args[0]);
52
53
System.out.println("Using " + fdsToUse + " fds.");
54
55
List<Thread> threads = new ArrayList<>();
56
for (int i=0; i<fdsToUse; i++)
57
threads.add(new WorkerThread());
58
59
for (Thread t : threads)
60
t.start();
61
62
for (Thread t : threads)
63
t.join();
64
}
65
66
static class WorkerThread extends Thread {
67
public void run() {
68
try (ServerSocket ss = new ServerSocket(0)) {
69
ss.setSoTimeout(2000);
70
ss.accept();
71
} catch (SocketTimeoutException x) {
72
// expected
73
} catch (IOException x) {
74
throw new java.io.UncheckedIOException(x);
75
}
76
}
77
}
78
}
79
80