Fix deadlocks caused by waiting for async operations to complete before the scheduler has started

This commit is contained in:
Luck 2016-10-22 09:21:30 +01:00
parent 9b92143501
commit 77e70ef8d3
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
7 changed files with 16 additions and 38 deletions

View File

@ -183,11 +183,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
// Run update task to refresh any online users
getLog().info("Scheduling Update Task to refresh any online users.");
try {
new UpdateTask(this).run();
} catch (Exception e) {
e.printStackTrace();
}
updateTaskBuffer.request();
registerPermissions(getConfiguration().isCommandsAllowOp() ? PermissionDefault.OP : PermissionDefault.FALSE);
if (!getConfiguration().isOpsEnabled()) {

View File

@ -148,11 +148,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
// Run update task to refresh any online users
getLog().info("Scheduling Update Task to refresh any online users.");
try {
new UpdateTask(this).run();
} catch (Exception e) {
e.printStackTrace();
}
updateTaskBuffer.request();
getLog().info("Successfully loaded.");
}

View File

@ -83,11 +83,8 @@ public class AbstractDatastore implements Datastore {
}
@Override
public LPFuture<Void> init() {
return makeFuture(() -> {
backing.init();
return null;
});
public void init() {
backing.init();
}
@Override

View File

@ -56,7 +56,7 @@ public interface Datastore {
return this;
}
LPFuture<Void> init();
void init();
LPFuture<Void> shutdown();
LPFuture<Boolean> logAction(LogEntry entry);
LPFuture<Log> getLog();

View File

@ -69,22 +69,16 @@ public class SplitBacking implements Datastore {
}
@Override
public LPFuture<Void> init() {
AbstractFuture<Void> future = new AbstractFuture<>();
doAsync(() -> {
boolean success = true;
backing.values().forEach(Datastore::init);
for (Datastore ds : backing.values()) {
if (!ds.isAcceptingLogins()) {
success = false;
}
public void init() {
boolean success = true;
backing.values().forEach(Datastore::init);
for (Datastore ds : backing.values()) {
if (!ds.isAcceptingLogins()) {
success = false;
}
}
setAcceptingLogins(success);
future.complete(null);
});
return future;
setAcceptingLogins(success);
}
@Override

View File

@ -77,7 +77,7 @@ public class StorageFactory {
}
plugin.getLog().info("Initialising datastore...");
datastore.init().getOrDefault(null);
datastore.init();
return datastore;
}

View File

@ -75,13 +75,8 @@ public class TolerantDatastore implements Datastore {
}
@Override
public LPFuture<Void> init() {
phaser.register();
try {
return backing.init();
} finally {
phaser.arriveAndDeregister();
}
public void init() {
backing.init();
}
@Override