mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
fixed an issue with client freezing
This commit is contained in:
parent
1ed3f1f4f8
commit
6048ee6538
3 changed files with 18 additions and 8 deletions
|
@ -31,11 +31,9 @@ package mage.interfaces.callback;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import mage.remote.Connection;
|
import mage.MageException;
|
||||||
import mage.remote.ServerUnavailable;
|
import mage.remote.ServerUnavailable;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.remote.method.Ack;
|
|
||||||
import mage.remote.method.Callback;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,8 +86,8 @@ public class CallbackClientDaemon extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ServerUnavailable ex) {
|
} catch (ServerUnavailable ex) {
|
||||||
session.disconnect(true);
|
session.handleServerUnavailable(ex);
|
||||||
} catch(Exception ex) {
|
} catch(MageException ex) {
|
||||||
logger.fatal("CallbackClientDaemon error ", ex);
|
logger.fatal("CallbackClientDaemon error ", ex);
|
||||||
session.disconnect(true);
|
session.disconnect(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class RemoteMethodCallQueue extends LinkedBlockingQueue<RemoteMethodCall>
|
||||||
public void callMethod(RemoteMethodCall call) throws ServerUnavailable, MageException {
|
public void callMethod(RemoteMethodCall call) throws ServerUnavailable, MageException {
|
||||||
synchronized (call) {
|
synchronized (call) {
|
||||||
try {
|
try {
|
||||||
this.put(call);
|
this.offer(call);
|
||||||
call.wait();
|
call.wait();
|
||||||
if (call.isException()) {
|
if (call.isException()) {
|
||||||
if (call.getException() != null)
|
if (call.getException() != null)
|
||||||
|
@ -54,4 +54,16 @@ public class RemoteMethodCallQueue extends LinkedBlockingQueue<RemoteMethodCall>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearCalls() {
|
||||||
|
RemoteMethodCall call = null;
|
||||||
|
while (true) {
|
||||||
|
call = poll();
|
||||||
|
if (call == null)
|
||||||
|
return;
|
||||||
|
synchronized (call) {
|
||||||
|
call.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupSession() {
|
private void cleanupSession() {
|
||||||
q.clear();
|
q.clearCalls();
|
||||||
if (future != null && !future.isDone())
|
if (future != null && !future.isDone())
|
||||||
future.cancel(true);
|
future.cancel(true);
|
||||||
if (callbackDaemon != null)
|
if (callbackDaemon != null)
|
||||||
|
@ -497,7 +497,7 @@ public class Session {
|
||||||
return handleCall(method);
|
return handleCall(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleServerUnavailable(ServerUnavailable ex) {
|
public void handleServerUnavailable(ServerUnavailable ex) {
|
||||||
sessionState = SessionState.SERVER_UNAVAILABLE;
|
sessionState = SessionState.SERVER_UNAVAILABLE;
|
||||||
logger.fatal("server unavailable - ", ex);
|
logger.fatal("server unavailable - ", ex);
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
|
|
Loading…
Reference in a new issue