test: fix random test failures
This commit is contained in:
@@ -271,23 +271,28 @@ public class Manager extends Emitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Manager.this._timeout >= 0) {
|
final long timeout = Manager.this._timeout;
|
||||||
final long timeout = Manager.this._timeout;
|
final Runnable onTimeout = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
logger.fine(String.format("connect attempt timed out after %d", timeout));
|
||||||
|
openSub.destroy();
|
||||||
|
socket.close();
|
||||||
|
socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (timeout == 0) {
|
||||||
|
EventThread.exec(onTimeout);
|
||||||
|
return;
|
||||||
|
} else if (Manager.this._timeout > 0) {
|
||||||
logger.fine(String.format("connection attempt will timeout after %d", timeout));
|
logger.fine(String.format("connection attempt will timeout after %d", timeout));
|
||||||
|
|
||||||
final Timer timer = new Timer();
|
final Timer timer = new Timer();
|
||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
EventThread.exec(new Runnable() {
|
EventThread.exec(onTimeout);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logger.fine(String.format("connect attempt timed out after %d", timeout));
|
|
||||||
openSub.destroy();
|
|
||||||
socket.close();
|
|
||||||
socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user