提交 b9e57e4d authored 作者: Thomas Mueller's avatar Thomas Mueller

./build.sh testNetwork could block if there was a network configuration problem.

上级 8f55701b
...@@ -628,7 +628,7 @@ public class Build extends BuildBase { ...@@ -628,7 +628,7 @@ public class Build extends BuildBase {
System.out.println(serverSocket); System.out.println(serverSocket);
int port = serverSocket.getLocalPort(); int port = serverSocket.getLocalPort();
final ServerSocket accept = serverSocket; final ServerSocket accept = serverSocket;
new Thread() { Thread thread = new Thread() {
public void run() { public void run() {
try { try {
System.out.println("server accepting"); System.out.println("server accepting");
...@@ -646,9 +646,11 @@ public class Build extends BuildBase { ...@@ -646,9 +646,11 @@ public class Build extends BuildBase {
t.printStackTrace(); t.printStackTrace();
} }
} }
}.start(); };
thread.start();
Thread.sleep(1000); Thread.sleep(1000);
Socket socket = new Socket(); Socket socket = new Socket();
socket.setSoTimeout(2000);
InetSocketAddress socketAddress = new InetSocketAddress(address, port); InetSocketAddress socketAddress = new InetSocketAddress(address, port);
System.out.println("client:" + socketAddress); System.out.println("client:" + socketAddress);
try { try {
...@@ -662,6 +664,12 @@ public class Build extends BuildBase { ...@@ -662,6 +664,12 @@ public class Build extends BuildBase {
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
thread.join(5000);
if (thread.isAlive()) {
System.out.println("thread is still alive, interrupting");
thread.interrupt();
}
Thread.sleep(100);
System.out.println("done"); System.out.println("done");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论