3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Ignore repeated shutdown requests.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-07 10:37:38 -04:00
Ursprung a7a227ed05
Commit a88d27af76

Datei anzeigen

@ -35,6 +35,7 @@ import java.nio.file.Paths;
import java.security.KeyPair; import java.security.KeyPair;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
public class VelocityServer implements ProxyServer { public class VelocityServer implements ProxyServer {
private static final Logger logger = LogManager.getLogger(VelocityServer.class); private static final Logger logger = LogManager.getLogger(VelocityServer.class);
@ -49,7 +50,7 @@ public class VelocityServer implements ProxyServer {
private KeyPair serverKeyPair; private KeyPair serverKeyPair;
private final ServerMap servers = new ServerMap(); private final ServerMap servers = new ServerMap();
private final CommandManager commandManager = new CommandManager(); private final CommandManager commandManager = new CommandManager();
private boolean shutdown = false; private final AtomicBoolean shutdown = new AtomicBoolean(false);
private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>(); private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>();
private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>(); private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>();
@ -136,15 +137,12 @@ public class VelocityServer implements ProxyServer {
} }
public boolean isShutdown() { public boolean isShutdown() {
return shutdown; return shutdown.get();
} }
public void shutdown() { public void shutdown() {
Preconditions.checkState(!shutdown, "Server already shut down"); if (!shutdown.compareAndSet(false, true)) return;
shutdown = true;
logger.info("Shutting down the proxy..."); logger.info("Shutting down the proxy...");
this.cm.shutdown(); this.cm.shutdown();
} }