do not run through connection loop after thread was interrupted and resolver returned 0 results
This commit is contained in:
parent
6121217df5
commit
681ce91ab8
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()) {
|
||||||
|
@ -1761,7 +1763,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bookmarksConversion() {
|
public boolean bookmarksConversion() {
|
||||||
return hasDiscoFeature(account.getJid().asBareJid(),Namespace.BOOKMARKS_CONVERSION) && pepPublishOptions();
|
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS_CONVERSION) && pepPublishOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean blocking() {
|
public boolean blocking() {
|
||||||
|
@ -1834,14 +1836,14 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean p1S3FileTransfer() {
|
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) {
|
public boolean httpUpload(long filesize) {
|
||||||
if (Config.DISABLE_HTTP_UPLOAD) {
|
if (Config.DISABLE_HTTP_UPLOAD) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} 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);
|
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(namespace);
|
||||||
if (items.size() > 0) {
|
if (items.size() > 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -1866,7 +1868,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMaxHttpUploadSize() {
|
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);
|
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(namespace);
|
||||||
if (items.size() > 0) {
|
if (items.size() > 0) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue