aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgenofire <geno+dev@fireorbit.de>2020-02-09 16:07:37 +0100
committergenofire <geno+dev@fireorbit.de>2020-02-09 23:10:17 +0100
commit6e9ea36d92917818a56c2c5440771cb0515e4fe7 (patch)
treed0111f9d969a967204a222ee555f71bd3bbbdf65
parentdb952297c516600547924aa6c9ebca53fd3bfea8 (diff)
improve logging of happy eyeball (v2)
-rw-r--r--src/main/java/de/pixart/messenger/utils/Resolver.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/Resolver.java b/src/main/java/de/pixart/messenger/utils/Resolver.java
index 596203342..464b17ddd 100644
--- a/src/main/java/de/pixart/messenger/utils/Resolver.java
+++ b/src/main/java/de/pixart/messenger/utils/Resolver.java
@@ -273,10 +273,15 @@ public class Resolver {
Result result;
if (r.size() == 1) {
result = r.get(0);
+ result.setLogID(logID);
result.connect();
return result;
}
+ for (Result res : r) {
+ res.setLogID(logID);
+ }
+
ExecutorService executor = Executors.newFixedThreadPool(4);
try {
@@ -328,6 +333,8 @@ public class Resolver {
private int priority;
private Socket socket;
+ private String logID;
+
static Result fromRecord(SRV srv, boolean directTls) {
Result result = new Result();
result.port = srv.port;
@@ -410,7 +417,11 @@ public class Resolver {
long time = System.currentTimeMillis();
this.socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);
time = System.currentTimeMillis() - time;
- Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result connect: " + toString() + " after: " + time + " ms");
+ if (!this.logID.isEmpty()) {
+ Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result (" + this.logID + ") connect: " + toString() + " after: " + time + " ms");
+ } else {
+ Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result connect: " + toString() + " after: " + time + " ms");
+ }
} catch (IOException e) {
e.printStackTrace();
this.disconnect();
@@ -418,20 +429,21 @@ public class Resolver {
}
public void disconnect() {
- this.disconnect("");
- }
- public void disconnect(String logID) {
if (this.socket != null ) {
FileBackend.close(this.socket);
this.socket = null;
- if (!logID.isEmpty()) {
- Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result (" + logID + ") disconnect: " + toString());
+ if (!this.logID.isEmpty()) {
+ Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result (" + this.logID + ") disconnect: " + toString());
} else {
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": Result disconnect: " + toString());
}
}
}
+ public void setLogID(String logID) {
+ this.logID = logID;
+ }
+
@Override
public int compareTo(@NonNull Result result) {
if (result.priority == priority) {