提交 42740063 编写于 作者: I igerasim

8146387: Test SSLSession/SessionCacheSizeTests socket accept timed out

Reviewed-by: weijun, wetmore
上级 df3488db
/* /*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -108,28 +108,34 @@ public class SessionCacheSizeTests { ...@@ -108,28 +108,34 @@ public class SessionCacheSizeTests {
void doServerSide(int serverPort, int serverConns) throws Exception { void doServerSide(int serverPort, int serverConns) throws Exception {
SSLServerSocket sslServerSocket = try (SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort); (SSLServerSocket) sslssf.createServerSocket(serverPort)) {
sslServerSocket.setSoTimeout(45000); // timeout to accept a connection
serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
/* // timeout to accept a connection
* Signal Client, we're ready for his connect. sslServerSocket.setSoTimeout(45000);
*/
if (createdPorts == serverPorts.length) { // make sure createdPorts++ is atomic
serverReady = true; synchronized(serverPorts) {
} serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
int read = 0;
int nConnections = 0; /*
/* * Signal Client, we're ready for his connect.
* Divide the max connections among the available server ports. */
* The use of more than one server port ensures creation of more if (createdPorts == serverPorts.length) {
* than one session. serverReady = true;
*/ }
SSLSession sessions [] = new SSLSession [serverConns]; }
SSLSessionContext sessCtx = sslctx.getServerSessionContext(); int read = 0;
int nConnections = 0;
/*
* Divide the max connections among the available server ports.
* The use of more than one server port ensures creation of more
* than one session.
*/
SSLSession sessions [] = new SSLSession [serverConns];
SSLSessionContext sessCtx = sslctx.getServerSessionContext();
try {
while (nConnections < serverConns) { while (nConnections < serverConns) {
try (SSLSocket sslSocket = try (SSLSocket sslSocket =
(SSLSocket)sslServerSocket.accept()) { (SSLSocket)sslServerSocket.accept()) {
...@@ -143,8 +149,6 @@ public class SessionCacheSizeTests { ...@@ -143,8 +149,6 @@ public class SessionCacheSizeTests {
nConnections++; nConnections++;
} }
} }
} finally {
sslServerSocket.close();
} }
} }
...@@ -270,8 +274,8 @@ public class SessionCacheSizeTests { ...@@ -270,8 +274,8 @@ public class SessionCacheSizeTests {
* Using four ports (one per each connection), we are able to create * Using four ports (one per each connection), we are able to create
* alteast four sessions. * alteast four sessions.
*/ */
volatile int serverPorts[] = new int[]{0, 0, 0, 0}; int serverPorts[] = new int[]{0, 0, 0, 0}; // MAX_ACTIVE_CONNECTIONS: 4
volatile int createdPorts = 0; int createdPorts = 0;
static SSLServerSocketFactory sslssf; static SSLServerSocketFactory sslssf;
static SSLSocketFactory sslsf; static SSLSocketFactory sslsf;
static SSLContext sslctx; static SSLContext sslctx;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册