Fix up PS & memory leak

This commit is contained in:
Sotr
2019-04-25 02:35:19 +08:00
parent 3db7f6990a
commit 2db912a9fd
3 changed files with 7 additions and 5 deletions

View File

@@ -62,7 +62,7 @@ public class BlockBeacon extends BlockTileEntity {
IBlockData iblockdata = world.getType(blockposition1);
if (iblockdata.getBlock() == Blocks.BEACON) {
((WorldServer) world).postToMainThread(() -> {
//((WorldServer) world).postToMainThread(() -> { // Akarin
TileEntity tileentity = world.getTileEntity(blockposition1);
if (tileentity instanceof TileEntityBeacon) {
@@ -70,7 +70,7 @@ public class BlockBeacon extends BlockTileEntity {
world.playBlockAction(blockposition1, Blocks.BEACON, 1, 0);
}
});
//}); // Akarin
}
}

View File

@@ -53,15 +53,16 @@ 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 Set<NetworkManager> pending = Sets.newConcurrentHashSet(); // Akarin - avoid same signature
private final List<NetworkManager> pending = Collections.synchronizedList(Lists.newArrayList());
// Akarin start
public final Set<NetworkManager> pendingRemoval = Sets.newHashSet(); // Akarin - avoid same signature
public final List<NetworkManager> pendingRemoval = Lists.newArrayList(); // Akarin - avoid same signature
private void addPending() {
/*synchronized (this.g)*/ { // Akarin
this.g.addAll(pending); // Paper - OBFHELPER - List of network managers
//pending.clear(); // Akarin - move down
}
pending.clear(); // Akarin - move from above
// Akarin end
}
// Paper end
@@ -134,6 +135,7 @@ public class ServerConnection {
synchronized (this.g) {
// Akarin start
this.g.removeAll(pendingRemoval);
pendingRemoval.clear();
addPending();
} {
// Akarin end