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) {
thread.interrupt();
}
synchronized (results) {
return new ArrayList<>(results);
}
return Collections.emptyList();
}
}

View File

@ -81,10 +81,10 @@ import eu.siacs.conversations.utils.Resolver;
import eu.siacs.conversations.utils.SSLSocketHelper;
import eu.siacs.conversations.utils.SocksSocketFactory;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xml.Tag;
import eu.siacs.conversations.xml.TagWriter;
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.Field;
import eu.siacs.conversations.xmpp.jingle.OnJinglePacketReceived;
@ -177,7 +177,6 @@ public class XmppConnection implements Runnable {
private CountDownLatch mStreamCountDownLatch;
public XmppConnection(final Account account, final XmppConnectionService service) {
this.account = account;
this.mXmppConnectionService = service;
@ -331,17 +330,20 @@ public class XmppConnection implements Runnable {
}
} else {
final String domain = account.getJid().getDomain();
List<Resolver.Result> results = Resolver.resolve(account.getJid().getDomain());
Resolver.Result storedBackupResult;
if (!Thread.currentThread().isInterrupted()) {
storedBackupResult = mXmppConnectionService.databaseBackend.findResolverResult(domain);
final List<Resolver.Result> results = Resolver.resolve(account.getJid().getDomain());
if (Thread.currentThread().isInterrupted()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": Thread was interrupted");
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)) {
results.add(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(); ) {
final Resolver.Result result = iterator.next();
if (Thread.currentThread().isInterrupted()) {
@ -1761,7 +1763,7 @@ public class XmppConnection implements Runnable {
}
public boolean bookmarksConversion() {
return hasDiscoFeature(account.getJid().asBareJid(),Namespace.BOOKMARKS_CONVERSION) && pepPublishOptions();
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS_CONVERSION) && pepPublishOptions();
}
public boolean blocking() {
@ -1834,14 +1836,14 @@ public class XmppConnection implements Runnable {
}
public boolean p1S3FileTransfer() {
return hasDiscoFeature(Jid.of(account.getServer()),Namespace.P1_S3_FILE_TRANSFER);
return hasDiscoFeature(Jid.of(account.getServer()), Namespace.P1_S3_FILE_TRANSFER);
}
public boolean httpUpload(long filesize) {
if (Config.DISABLE_HTTP_UPLOAD) {
return false;
} else {
for(String namespace : new String[]{Namespace.HTTP_UPLOAD, Namespace.HTTP_UPLOAD_LEGACY}) {
for (String namespace : new String[]{Namespace.HTTP_UPLOAD, Namespace.HTTP_UPLOAD_LEGACY}) {
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(namespace);
if (items.size() > 0) {
try {
@ -1866,7 +1868,7 @@ public class XmppConnection implements Runnable {
}
public long getMaxHttpUploadSize() {
for(String namespace : new String[]{Namespace.HTTP_UPLOAD, Namespace.HTTP_UPLOAD_LEGACY}) {
for (String namespace : new String[]{Namespace.HTTP_UPLOAD, Namespace.HTTP_UPLOAD_LEGACY}) {
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(namespace);
if (items.size() > 0) {
try {