diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-12 21:54:42 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-05-13 21:56:24 +0200 |
commit | 293d87793adde2e63b6916860adbb72c1b6b3e49 (patch) | |
tree | ecca3e2792c4f279dbdcb77e77151d7a71427437 /src/main/java/eu/siacs/conversations/utils | |
parent | f5017c3da8143af3ef4d7a9ab37e3fba4260e939 (diff) |
interrupt XMPPConnection Thread
in some cases the the DNS query might take too long (even though we specified a timeout)
if that happens we need a secondary solution (besides killing the socket) to stop the thread
Diffstat (limited to 'src/main/java/eu/siacs/conversations/utils')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/DNSHelper.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index b96d3c256..2f588f492 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -51,14 +51,19 @@ public class DNSHelper { final String host = jid.getDomainpart(); final List<InetAddress> servers = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDnsServers(context) : getDnsServersPreLollipop(); Bundle b = new Bundle(); + boolean interrupted = false; for(InetAddress server : servers) { + if (Thread.currentThread().isInterrupted()) { + interrupted = true; + break; + } b = queryDNS(host, server); if (b.containsKey("values")) { return b; } } if (!b.containsKey("values")) { - Log.d(Config.LOGTAG,"all dns queries failed. provide fallback A record"); + Log.d(Config.LOGTAG,(interrupted ? "Thread interrupted during DNS query" :"all dns queries failed") + ". provide fallback A record"); ArrayList<Parcelable> values = new ArrayList<>(); values.add(createNamePortBundle(host, 5222, false)); b.putParcelableArrayList("values",values); |