improve logging of happy eyeball
This commit is contained in:
parent
0e32326d22
commit
1bac752e30
|
@ -136,14 +136,12 @@ public class Resolver {
|
||||||
threads[2].interrupt();
|
threads[2].interrupt();
|
||||||
synchronized (results) {
|
synchronized (results) {
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results.toString());
|
|
||||||
return happyEyeball(results);
|
return happyEyeball(results);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
threads[2].join();
|
threads[2].join();
|
||||||
synchronized (fallbackResults) {
|
synchronized (fallbackResults) {
|
||||||
Collections.sort(fallbackResults);
|
Collections.sort(fallbackResults);
|
||||||
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults.toString());
|
|
||||||
return happyEyeball(fallbackResults);
|
return happyEyeball(fallbackResults);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +260,8 @@ public class Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result happyEyeball(List<Result> r) {
|
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;
|
if (r.size() == 0) return null;
|
||||||
|
|
||||||
Result result;
|
Result result;
|
||||||
|
@ -280,22 +280,22 @@ public class Resolver {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
if (executor.awaitTermination(5, TimeUnit.SECONDS)) break;
|
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) {}
|
} catch (InterruptedException e) {}
|
||||||
}
|
}
|
||||||
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) {
|
for (Result re : r) {
|
||||||
if(!re.equals(result)) re.disconnect();
|
if(!re.equals(result)) re.disconnect(logID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
disconnector.start();
|
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;
|
return result;
|
||||||
} catch (InterruptedException e) {
|
} 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;
|
return null;
|
||||||
} catch (ExecutionException e) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,10 +408,17 @@ public class Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
|
this.disconnect("");
|
||||||
|
}
|
||||||
|
public void disconnect(String logID) {
|
||||||
if (this.socket != null ) {
|
if (this.socket != null ) {
|
||||||
FileBackend.close(this.socket);
|
FileBackend.close(this.socket);
|
||||||
this.socket = null;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue