Put lock in a more strategic location

This commit is contained in:
ME1312 2021-02-24 17:13:26 -05:00
parent f90a54e636
commit 2beec3ae7a
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8

View File

@ -137,7 +137,6 @@ public class InternalSubServer extends SubServerImpl {
} }
private void run() { private void run() {
lock = false;
allowrestart = true; allowrestart = true;
started = false; started = false;
try { try {
@ -151,6 +150,7 @@ public class InternalSubServer extends SubServerImpl {
Logger.get("SubServers").info("Now starting " + getName()); Logger.get("SubServers").info("Now starting " + getName());
logger.process = process; logger.process = process;
logger.start(); logger.start();
lock = false;
command = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); command = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
for (LoggedCommand command : history) if (process.isAlive()) { for (LoggedCommand command : history) if (process.isAlive()) {
this.command.write(command.getCommand()); this.command.write(command.getCommand());
@ -162,6 +162,7 @@ public class InternalSubServer extends SubServerImpl {
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
allowrestart = false; allowrestart = false;
lock = false;
} }
Logger.get("SubServers").info(getName() + " has stopped"); Logger.get("SubServers").info(getName() + " has stopped");