Skip to content

Commit

Permalink
[UNDERTOW-2405] Remove new max connections per listener config, we ca…
Browse files Browse the repository at this point in the history
…n use high and low watermarks for this

This reverts commit c27c1e4.

Signed-off-by: Flavia Rainone <frainone@redhat.com>
  • Loading branch information
fl4via committed Jun 17, 2024
1 parent c27c1e4 commit 5e141ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@

package io.undertow.server.protocol.http;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.xnio.ChannelListener;
import org.xnio.IoUtils;
import org.xnio.OptionMap;
import org.xnio.Options;
import org.xnio.Pool;
import org.xnio.StreamConnection;

import io.undertow.UndertowLogger;
import io.undertow.UndertowMessages;
import io.undertow.UndertowOptions;
Expand All @@ -34,18 +47,6 @@
import io.undertow.server.HttpHandler;
import io.undertow.server.ServerConnection;
import io.undertow.server.XnioByteBufferPool;
import org.xnio.ChannelListener;
import org.xnio.IoUtils;
import org.xnio.OptionMap;
import org.xnio.Options;
import org.xnio.Pool;
import org.xnio.StreamConnection;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
* Open listener for HTTP server. XNIO should be set up to chain the accept handler to post-accept open
Expand All @@ -55,8 +56,6 @@
*/
public final class HttpOpenListener implements ChannelListener<StreamConnection>, DelegateOpenListener {

private static final int DEFAULT_MAX_CONNECTIONS_PER_LISTENER = 100;
private static final int MAX_CONNECTIONS_PER_LISTENER = Integer.getInteger("io.undertow.max-connections-per-listener", DEFAULT_MAX_CONNECTIONS_PER_LISTENER);
private final Set<HttpServerConnection> connections = Collections.newSetFromMap(new ConcurrentHashMap<>());

private final ByteBufferPool bufferPool;
Expand Down Expand Up @@ -103,12 +102,6 @@ public void handleEvent(StreamConnection channel) {

@Override
public void handleEvent(final StreamConnection channel, PooledByteBuffer buffer) {
if (connections.size() >= MAX_CONNECTIONS_PER_LISTENER) {
UndertowLogger.REQUEST_IO_LOGGER.debugf("Reached maximum number of connections %d per listener; closing open connection request from %s",
MAX_CONNECTIONS_PER_LISTENER, channel.getPeerAddress());
IoUtils.safeClose(channel);
return;
}
if (UndertowLogger.REQUEST_LOGGER.isTraceEnabled()) {
UndertowLogger.REQUEST_LOGGER.tracef("Opened connection with %s", channel.getPeerAddress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
*/
public final class Http2OpenListener implements ChannelListener<StreamConnection>, DelegateOpenListener {

private static final int DEFAULT_MAX_CONNECTIONS_PER_LISTENER = 100;
private static final int MAX_CONNECTIONS_PER_LISTENER = Integer.getInteger("io.undertow.max-connections-per-listener", DEFAULT_MAX_CONNECTIONS_PER_LISTENER);

private final Set<Http2Channel> connections = Collections.newSetFromMap(new ConcurrentHashMap<>());


Expand Down Expand Up @@ -114,12 +113,7 @@ public void handleEvent(final StreamConnection channel, PooledByteBuffer buffer)
if (UndertowLogger.REQUEST_LOGGER.isTraceEnabled()) {
UndertowLogger.REQUEST_LOGGER.tracef("Opened HTTP/2 connection with %s", channel.getPeerAddress());
}
if (connections.size() >= MAX_CONNECTIONS_PER_LISTENER) {
UndertowLogger.REQUEST_IO_LOGGER.debugf("Reached maximum number of connections %d per listener; closing open connection request from %s",
MAX_CONNECTIONS_PER_LISTENER, channel.getPeerAddress());
IoUtils.safeClose(channel);
return;
}

//cool, we have a Http2 connection.
Http2Channel http2Channel = new Http2Channel(channel, protocol, bufferPool, buffer, false, false, undertowOptions);
Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT);
Expand Down

0 comments on commit 5e141ab

Please sign in to comment.