2020-10-05 16:53:08 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
|
|
Date: Mon, 5 Oct 2020 17:09:00 +0300
|
|
|
|
Subject: [PATCH] Ensure pools create daemon threads
|
|
|
|
|
|
|
|
If only 1 non-daemon thread is left to run when the server is shutting down, the server won't shut down.
|
|
|
|
This patche ensures that executors make daemon threads.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
2020-11-07 08:02:33 +01:00
|
|
|
index 2fa0f21cfa81670f6c3f18f76e7fa8d0bb541f11..9190caed195b9987e3af545f4de63b8d956788a6 100644
|
2020-10-05 16:53:08 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
2020-11-07 08:02:33 +01:00
|
|
|
@@ -108,7 +108,11 @@ public class LoginListener implements PacketLoginInListener {
|
2020-10-05 16:53:08 +02:00
|
|
|
// Paper start - Cache authenticator threads
|
|
|
|
private static final AtomicInteger threadId = new AtomicInteger(0);
|
|
|
|
private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(
|
|
|
|
- r -> new Thread(r, "User Authenticator #" + threadId.incrementAndGet())
|
|
|
|
+ r -> { // Yatopia start - make sure produced threads are daemon ones
|
|
|
|
+ Thread thread = new Thread(r, "User Authenticator #" + threadId.incrementAndGet());
|
|
|
|
+ thread.setDaemon(true);
|
|
|
|
+ return thread;
|
|
|
|
+ } // Yatopia end
|
|
|
|
);
|
|
|
|
// Paper end
|
|
|
|
// Spigot start
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
2020-10-08 13:04:22 +02:00
|
|
|
index 653ba0f1d84af1997d768426d3542c9d465f6c93..748742fb03c6066a72ac6046a96e8d9f8fad2694 100644
|
2020-10-05 16:53:08 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
|
|
|
@@ -42,12 +42,12 @@ public final class MCUtil {
|
|
|
|
public static final ThreadPoolExecutor asyncExecutor = new ThreadPoolExecutor(
|
|
|
|
0, 2, 60L, TimeUnit.SECONDS,
|
|
|
|
new LinkedBlockingQueue<Runnable>(),
|
|
|
|
- new ThreadFactoryBuilder().setNameFormat("Paper Async Task Handler Thread - %1$d").build()
|
|
|
|
+ new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Paper Async Task Handler Thread - %1$d").build() // Yatopia - daemon
|
|
|
|
);
|
|
|
|
public static final ThreadPoolExecutor cleanerExecutor = new ThreadPoolExecutor(
|
|
|
|
1, 1, 0L, TimeUnit.SECONDS,
|
|
|
|
new LinkedBlockingQueue<Runnable>(),
|
|
|
|
- new ThreadFactoryBuilder().setNameFormat("Paper Object Cleaner").build()
|
|
|
|
+ new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Paper Object Cleaner").build() // Yatopia - daemon
|
|
|
|
);
|
|
|
|
|
|
|
|
public static final long INVALID_CHUNK_KEY = getCoordinateKey(Integer.MAX_VALUE, Integer.MAX_VALUE);
|