Reorganizing the removal of awaiting commands and so forth in hopes that lock-ups don't happen on reconnect.
This commit is contained in:
+15
-8
@@ -359,8 +359,16 @@ public class LocalTeamspeakClientSocket
|
|||||||
|
|
||||||
// Free stuff
|
// Free stuff
|
||||||
serverId = null;
|
serverId = null;
|
||||||
awaitingCommands.clear();
|
|
||||||
acceptingReturnCode = 0;
|
|
||||||
|
synchronized (commandSendLock) {
|
||||||
|
for (Integer id : new ArrayList<>(awaitingCommands.keySet())) {
|
||||||
|
ClientCommandResponse response = awaitingCommands.get(id);
|
||||||
|
response.completeFailure(new IOException("client disconnected"));
|
||||||
|
}
|
||||||
|
awaitingCommands.clear();
|
||||||
|
calculateAcceptingReturnCode();
|
||||||
|
}
|
||||||
|
|
||||||
setOption("client.hostname", remote.getHostString());
|
setOption("client.hostname", remote.getHostString());
|
||||||
|
|
||||||
@@ -604,11 +612,6 @@ public class LocalTeamspeakClientSocket
|
|||||||
|
|
||||||
private void handleComplete(SingleCommand command) throws IOException, TimeoutException {
|
private void handleComplete(SingleCommand command) throws IOException, TimeoutException {
|
||||||
try {
|
try {
|
||||||
synchronized (commandSendLock) {
|
|
||||||
awaitingCommands.remove(returnCode);
|
|
||||||
acceptingReturnCode = calculateAcceptingReturnCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
int errorId = Integer.parseInt(command.get("id").getValue());
|
int errorId = Integer.parseInt(command.get("id").getValue());
|
||||||
|
|
||||||
switch (errorId) {
|
switch (errorId) {
|
||||||
@@ -621,7 +624,11 @@ public class LocalTeamspeakClientSocket
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
completeFailure(e);
|
completeFailure(e);
|
||||||
} finally {
|
} finally {
|
||||||
sendNextCommand();
|
synchronized (commandSendLock) {
|
||||||
|
awaitingCommands.remove(getReturnCode());
|
||||||
|
acceptingReturnCode = calculateAcceptingReturnCode();
|
||||||
|
sendNextCommand();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user