Skip to content

Commit

Permalink
make simplepool thread names generic (not related to http/1.1 or http/2
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Christoff committed Jan 26, 2024
1 parent f87c2f0 commit 0b965ae
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public SimpleConnection makeConnection(
final Set<SimpleConnection> allCreatedConnections) throws RuntimeException
{
boolean isHttps = uri.getScheme().equalsIgnoreCase("https");
XnioWorker worker = getWorker(isHttp2);
XnioSsl ssl = getSSL(isHttps, isHttp2);
XnioWorker worker = getWorker();
XnioSsl ssl = getSSL(isHttps);
OptionMap connectionOptions = getConnectionOptions(isHttp2);
InetSocketAddress bindAddress = null;

Expand Down Expand Up @@ -138,10 +138,9 @@ private static OptionMap getConnectionOptions(boolean isHttp2) {
* WARNING: This is called by getSSL(). Therefore, this method must never
* call getSSL(), or any method that transitively calls getSSL()
*
* @param isHttp2 if true, sets worker thread names to show HTTP2
* @return new XnioWorker
*/
private static XnioWorker getWorker(boolean isHttp2)
private static XnioWorker getWorker()
{
if(WORKER.get() != null) return WORKER.get();

Expand All @@ -151,7 +150,7 @@ private static XnioWorker getWorker(boolean isHttp2)

Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
try {
WORKER.set(xnio.createWorker(null, getWorkerOptionMap(isHttp2)));
WORKER.set(xnio.createWorker(null, getWorkerOptionMap()));
} catch (IOException e) {
logger.error("Exception while creating new XnioWorker", e);
throw new RuntimeException(e);
Expand All @@ -160,13 +159,13 @@ private static XnioWorker getWorker(boolean isHttp2)
return WORKER.get();
}

private static OptionMap getWorkerOptionMap(boolean isHttp2)
private static OptionMap getWorkerOptionMap()
{
OptionMap.Builder optionBuild = OptionMap.builder()
.set(Options.WORKER_IO_THREADS, 8)
.set(Options.TCP_NODELAY, true)
.set(Options.KEEP_ALIVE, true)
.set(Options.WORKER_NAME, isHttp2 ? "Callback-HTTP2" : "Callback-HTTP11");
.set(Options.WORKER_NAME, "simplepool");
return optionBuild.getMap();
}

Expand All @@ -176,10 +175,9 @@ private static OptionMap getWorkerOptionMap(boolean isHttp2)
* WARNING: This calls getWorker()
*
* @param isHttps true if this is an HTTPS connection
* @param isHttp2 if true, sets worker thread names to show HTTP2
* @return new XnioSSL
*/
private static XnioSsl getSSL(boolean isHttps, boolean isHttp2)
private static XnioSsl getSSL(boolean isHttps)
{
if(!isHttps) return null;
if(SSL.get() != null) return SSL.get();
Expand All @@ -189,7 +187,7 @@ private static XnioSsl getSSL(boolean isHttps, boolean isHttp2)
if(SSL.get() != null) return SSL.get();

try {
SSL.set(new UndertowXnioSsl(getWorker(isHttp2).getXnio(), OptionMap.EMPTY, BUFFER_POOL, SimpleSSLContextMaker.createSSLContext()));
SSL.set(new UndertowXnioSsl(getWorker().getXnio(), OptionMap.EMPTY, BUFFER_POOL, SimpleSSLContextMaker.createSSLContext()));
} catch (Exception e) {
logger.error("Exception while creating new shared UndertowXnioSsl used to create connections", e);
throw new RuntimeException(e);
Expand Down

0 comments on commit 0b965ae

Please sign in to comment.