Fix startup deadlock

This commit is contained in:
Luck 2017-09-13 21:24:35 +01:00
parent 2412edaa3a
commit 67602b8d85
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
5 changed files with 18 additions and 5 deletions

View File

@ -76,6 +76,7 @@ import me.lucko.luckperms.common.storage.StorageType;
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import me.lucko.luckperms.common.tasks.UpdateTask;
import me.lucko.luckperms.common.treeview.PermissionVault;
import me.lucko.luckperms.common.utils.LoginHelper;
import me.lucko.luckperms.common.utils.UuidCache;
@ -273,7 +274,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly();
new UpdateTask(this, true).run();
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);

View File

@ -72,6 +72,7 @@ import me.lucko.luckperms.common.storage.StorageType;
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import me.lucko.luckperms.common.tasks.UpdateTask;
import me.lucko.luckperms.common.treeview.PermissionVault;
import me.lucko.luckperms.common.utils.UuidCache;
import me.lucko.luckperms.common.verbose.VerboseHandler;
@ -200,7 +201,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly();
new UpdateTask(this, true).run();
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);

View File

@ -38,7 +38,7 @@ public class UpdateTaskBuffer extends BufferedRequest<Void> {
@Override
protected Void perform() {
new UpdateTask(plugin).run();
new UpdateTask(plugin, false).run();
return null;
}
}

View File

@ -31,10 +31,17 @@ import me.lucko.luckperms.api.event.cause.CreationCause;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import java.util.concurrent.CompletableFuture;
@AllArgsConstructor
public class UpdateTask implements Runnable {
private final LuckPermsPlugin plugin;
/**
* If this task is being called before the server has fully started
*/
private final boolean initialUpdate;
/**
* Called ASYNC
*/
@ -55,7 +62,10 @@ public class UpdateTask implements Runnable {
plugin.getStorage().loadAllTracks().join();
// Refresh all online users.
plugin.getUserManager().updateAllUsers().join();
CompletableFuture<Void> userUpdateFut = plugin.getUserManager().updateAllUsers();
if (!initialUpdate) {
userUpdateFut.join();
}
plugin.onPostUpdate();

View File

@ -65,6 +65,7 @@ import me.lucko.luckperms.common.storage.StorageType;
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
import me.lucko.luckperms.common.tasks.UpdateTask;
import me.lucko.luckperms.common.treeview.PermissionVault;
import me.lucko.luckperms.common.utils.UuidCache;
import me.lucko.luckperms.common.verbose.VerboseHandler;
@ -264,7 +265,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
updateTaskBuffer.requestDirectly();
new UpdateTask(this, true).run();
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);