fix interlocks
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
0ab39b24f6
commit
2972e82f4a
@ -127,16 +127,16 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
||||
|
||||
/** Disconnect the current input. */
|
||||
public void disconnect() {
|
||||
synchronized (promptLock) {
|
||||
synchronized (connectionLock) {
|
||||
if (connected != null) {
|
||||
disconnection = true;
|
||||
synchronized (promptLock) {
|
||||
connected.interruptPrompt();
|
||||
}
|
||||
connected = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see fr.bigeon.gclc.manager.ConsoleInput#getPrompt() */
|
||||
@ -191,7 +191,7 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
||||
if (!prompting) {
|
||||
return null;
|
||||
}
|
||||
boolean connect = true;
|
||||
boolean connect;
|
||||
synchronized (connectionLock) {
|
||||
connect = connected != null;
|
||||
}
|
||||
@ -234,7 +234,11 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
||||
if (!prompting) {
|
||||
return null;
|
||||
}
|
||||
if (connected == null) {
|
||||
boolean connect;
|
||||
synchronized (connectionLock) {
|
||||
connect = connected != null;
|
||||
}
|
||||
if (!connect) {
|
||||
try {
|
||||
promptLock.wait(timeout);
|
||||
} catch (final InterruptedException e) {
|
||||
@ -242,9 +246,9 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} else {
|
||||
synchronized (connectionLock) {
|
||||
final String res = connected.prompt(message,
|
||||
end - System.currentTimeMillis());
|
||||
synchronized (connectionLock) {
|
||||
if (disconnection) {
|
||||
disconnection = false;
|
||||
} else if (prompting) {
|
||||
|
Loading…
Reference in New Issue
Block a user