Stop clients when interrupted
This commit is contained in:
parent
340ad5f6d1
commit
9b449fd3a8
@ -65,7 +65,9 @@ public final class ResponseReceiver extends Thread implements AutoCloseable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
int[] sortIndex;
|
int[] sortIndex;
|
||||||
try {
|
try {
|
||||||
while (!Thread.interrupted() && ((!closeCalled.get() && !jvmShutdown.get()) || !registeredClients.isEmpty())) {
|
boolean interrupted;
|
||||||
|
while (!(interrupted = Thread.interrupted())
|
||||||
|
&& ((!closeCalled.get() && !jvmShutdown.get()) || !registeredClients.isEmpty())) {
|
||||||
int resultsCount = NativeClientAccess.receive(clientIds, eventIds, events, 2.0 /*seconds*/);
|
int resultsCount = NativeClientAccess.receive(clientIds, eventIds, events, 2.0 /*seconds*/);
|
||||||
|
|
||||||
if (resultsCount <= 0) {
|
if (resultsCount <= 0) {
|
||||||
@ -165,6 +167,16 @@ public final class ResponseReceiver extends Thread implements AutoCloseable {
|
|||||||
this.registeredClients.addAll(closedClients);
|
this.registeredClients.addAll(closedClients);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (interrupted) {
|
||||||
|
if (!jvmShutdown.get()) {
|
||||||
|
for (Integer clientId : this.registeredClients) {
|
||||||
|
long[] clientEventIds = new long[0];
|
||||||
|
TdApi.Object[] clientEvents = new TdApi.Object[0];
|
||||||
|
eventsHandler.handleClientEvents(clientId, true, clientEventIds, clientEvents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.closeWait.countDown();
|
this.closeWait.countDown();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user