diff options
author | genofire <geno+dev@fireorbit.de> | 2020-02-09 12:55:56 +0100 |
---|---|---|
committer | genofire <geno+dev@fireorbit.de> | 2020-02-09 13:12:03 +0100 |
commit | fc0daaf81de559a65002c30c2c0a0bb0b38f1af1 (patch) | |
tree | b0477005520d1a6c98d266b02d249767239ca5fb /src/main/java/de/pixart/messenger | |
parent | afcfd057d8ad9333532eeeba162c903d881d555f (diff) |
improve logging of happy eyeball
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Resolver.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/Resolver.java b/src/main/java/de/pixart/messenger/utils/Resolver.java index d5c23f700..596203342 100644 --- a/src/main/java/de/pixart/messenger/utils/Resolver.java +++ b/src/main/java/de/pixart/messenger/utils/Resolver.java @@ -139,14 +139,12 @@ public class Resolver { threads[2].interrupt(); synchronized (results) { Collections.sort(results); - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results.toString()); return happyEyeball(results); } } else { threads[2].join(); synchronized (fallbackResults) { Collections.sort(fallbackResults); - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults.toString()); return happyEyeball(fallbackResults); } } @@ -268,6 +266,8 @@ public class Resolver { } private static Result happyEyeball(List<Result> r) { + String logID = Long.toHexString(Double.doubleToLongBits(Math.random())); + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") with " + r.toString()); if (r.size() == 0) return null; Result result; @@ -286,24 +286,24 @@ public class Resolver { while (true) { try { if (executor.awaitTermination(5, TimeUnit.SECONDS)) break; - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball wait for cleanup ..."); + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") wait for cleanup ..."); } catch (InterruptedException e) { e.printStackTrace(); } } - Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball cleanup"); + Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") cleanup"); for (Result re : r) { if(!re.equals(result)) re.disconnect(); } }); disconnector.start(); - Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball used: " + result.toString()); + Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") used: " + result.toString()); return result; } catch (InterruptedException e) { - Log.e(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball failed: ", e); + Log.e(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") failed: ", e); return null; } catch (ExecutionException e) { - Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball unable to connect to one address"); + Log.i(Config.LOGTAG, Resolver.class.getSimpleName() + ": happy eyeball (" + logID + ") unable to connect to one address"); return null; } } @@ -418,10 +418,17 @@ public class Resolver { } public void disconnect() { + this.disconnect(""); + } + public void disconnect(String logID) { if (this.socket != null ) { FileBackend.close(this.socket); this.socket = null; - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result disconnect: " + toString()); + if (!logID.isEmpty()) { + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result (" + logID + ") disconnect: " + toString()); + } else { + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result disconnect: " + toString()); + } } } |