do not run through connection loop after thread was interrupted and resolver returned 0 results

This commit is contained in:
Daniel Gultsch 2018-09-26 14:39:04 +02:00
parent 6121217df5
commit 681ce91ab8
2 changed files with 1783 additions and 1783 deletions

View file

@ -123,9 +123,7 @@ public class Resolver {
for(Thread thread : threads) { for(Thread thread : threads) {
thread.interrupt(); thread.interrupt();
} }
synchronized (results) { return Collections.emptyList();
return new ArrayList<>(results);
}
} }
} }

View file

@ -81,10 +81,10 @@ import eu.siacs.conversations.utils.Resolver;
import eu.siacs.conversations.utils.SSLSocketHelper; import eu.siacs.conversations.utils.SSLSocketHelper;
import eu.siacs.conversations.utils.SocksSocketFactory; import eu.siacs.conversations.utils.SocksSocketFactory;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xml.Tag; import eu.siacs.conversations.xml.Tag;
import eu.siacs.conversations.xml.TagWriter; import eu.siacs.conversations.xml.TagWriter;
import eu.siacs.conversations.xml.XmlReader; import eu.siacs.conversations.xml.XmlReader;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.xmpp.forms.Field;
import eu.siacs.conversations.xmpp.jingle.OnJinglePacketReceived; import eu.siacs.conversations.xmpp.jingle.OnJinglePacketReceived;
@ -177,7 +177,6 @@ public class XmppConnection implements Runnable {
private CountDownLatch mStreamCountDownLatch; private CountDownLatch mStreamCountDownLatch;
public XmppConnection(final Account account, final XmppConnectionService service) { public XmppConnection(final Account account, final XmppConnectionService service) {
this.account = account; this.account = account;
this.mXmppConnectionService = service; this.mXmppConnectionService = service;
@ -331,17 +330,20 @@ public class XmppConnection implements Runnable {
} }
} else { } else {
final String domain = account.getJid().getDomain(); final String domain = account.getJid().getDomain();
List<Resolver.Result> results = Resolver.resolve(account.getJid().getDomain()); final List<Resolver.Result> results = Resolver.resolve(account.getJid().getDomain());
Resolver.Result storedBackupResult; if (Thread.currentThread().isInterrupted()) {
if (!Thread.currentThread().isInterrupted()) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": Thread was interrupted");
storedBackupResult = mXmppConnectionService.databaseBackend.findResolverResult(domain); return;
}
if (results.size() == 0) {
Log.e(Config.LOGTAG,account.getJid().asBareJid()+": Resolver results were empty");
return;
}
final Resolver.Result storedBackupResult = mXmppConnectionService.databaseBackend.findResolverResult(domain);
if (storedBackupResult != null && !results.contains(storedBackupResult)) { if (storedBackupResult != null && !results.contains(storedBackupResult)) {
results.add(storedBackupResult); results.add(storedBackupResult);
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": loaded backup resolver result from db: " + storedBackupResult); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": loaded backup resolver result from db: " + storedBackupResult);
} }
} else {
storedBackupResult = null;
}
for (Iterator<Resolver.Result> iterator = results.iterator(); iterator.hasNext(); ) { for (Iterator<Resolver.Result> iterator = results.iterator(); iterator.hasNext(); ) {
final Resolver.Result result = iterator.next(); final Resolver.Result result = iterator.next();
if (Thread.currentThread().isInterrupted()) { if (Thread.currentThread().isInterrupted()) {