geforkt von Mirrors/Velocity
Allow closing active proxy listeners (#1109)
Dieser Commit ist enthalten in:
Ursprung
b30802c1b3
Commit
b33d18af2b
@ -41,6 +41,12 @@ public interface ProxyServer extends Audience {
|
|||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes all listening endpoints for this server.
|
||||||
|
* This includes the main minecraft listener and query channel.
|
||||||
|
*/
|
||||||
|
void closeListeners();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the player currently connected to this proxy by their Minecraft username. The search
|
* Retrieves the player currently connected to this proxy by their Minecraft username. The search
|
||||||
* is case-insensitive.
|
* is case-insensitive.
|
||||||
|
@ -572,6 +572,11 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
shutdown(true);
|
shutdown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeListeners() {
|
||||||
|
this.cm.closeEndpoints(false);
|
||||||
|
}
|
||||||
|
|
||||||
public AsyncHttpClient getAsyncHttpClient() {
|
public AsyncHttpClient getAsyncHttpClient() {
|
||||||
return cm.getHttpClient();
|
return cm.getHttpClient();
|
||||||
}
|
}
|
||||||
|
@ -212,9 +212,11 @@ public final class ConnectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes all endpoints.
|
* Closes all the currently registered endpoints.
|
||||||
|
*
|
||||||
|
* @param interrupt should closing forward interruptions
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void closeEndpoints(boolean interrupt) {
|
||||||
for (final Map.Entry<InetSocketAddress, Endpoint> entry : this.endpoints.entrySet()) {
|
for (final Map.Entry<InetSocketAddress, Endpoint> entry : this.endpoints.entrySet()) {
|
||||||
final InetSocketAddress address = entry.getKey();
|
final InetSocketAddress address = entry.getKey();
|
||||||
final Endpoint endpoint = entry.getValue();
|
final Endpoint endpoint = entry.getValue();
|
||||||
@ -223,14 +225,26 @@ public final class ConnectionManager {
|
|||||||
// should have a chance to be notified before the server stops accepting connections.
|
// should have a chance to be notified before the server stops accepting connections.
|
||||||
server.getEventManager().fire(new ListenerCloseEvent(address, endpoint.getType())).join();
|
server.getEventManager().fire(new ListenerCloseEvent(address, endpoint.getType())).join();
|
||||||
|
|
||||||
try {
|
LOGGER.info("Closing endpoint {}", address);
|
||||||
LOGGER.info("Closing endpoint {}", address);
|
if (interrupt) {
|
||||||
endpoint.getChannel().close().sync();
|
try {
|
||||||
} catch (final InterruptedException e) {
|
endpoint.getChannel().close().sync();
|
||||||
LOGGER.info("Interrupted whilst closing endpoint", e);
|
} catch (final InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
LOGGER.info("Interrupted whilst closing endpoint", e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
endpoint.getChannel().close().syncUninterruptibly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.endpoints.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes all endpoints.
|
||||||
|
*/
|
||||||
|
public void shutdown() {
|
||||||
|
this.closeEndpoints(true);
|
||||||
|
|
||||||
this.resolver.shutdown();
|
this.resolver.shutdown();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren