Actually resolve similar issues

This commit is contained in:
Sotr
2019-04-16 23:30:38 +08:00
parent 328079cab3
commit d419e8b12c

View File

@@ -1,6 +1,7 @@
package net.minecraft.server;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
@@ -21,9 +22,13 @@ import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.util.concurrent.Future;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -47,9 +52,9 @@ public class ServerConnection {
private final List<ChannelFuture> f = Collections.synchronizedList(Lists.newArrayList());
private final List<NetworkManager> g = Collections.synchronizedList(Lists.newArrayList()); public final List<NetworkManager> getNetworkManagers() { return this.g; } // Akarin
// Paper start - prevent blocking on adding a new network manager while the server is ticking
private final List<NetworkManager> pending = Lists.newCopyOnWriteArrayList();
private final Set<NetworkManager> pending = Sets.newConcurrentHashSet(); // Akarin - avoid same signature
// Akarin start
private final List<NetworkManager> pendingRemoval = Lists.newArrayList();
public final Set<NetworkManager> pendingRemoval = Sets.newHashSet(); // Akarin - avoid same signature
private void addPending() {
/*synchronized (this.g)*/ { // Akarin
this.g.addAll(pending); // Paper - OBFHELPER - List of network managers