Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix SRV handling and a couple of NPEs.

SRV lookup failure was being cached.
  • Loading branch information...
commit ed064a8af57af421d16e784ba2cbfbb9fcf15948 1 parent 88e3df6
@devrandom authored
View
2  src/info/guardianproject/otr/OtrEngineHostImpl.java
@@ -65,8 +65,6 @@ public void addConnection (ImConnectionAdapter connection)
public void removeConnection (ImConnectionAdapter connection)
{
mConnections.remove(connection);
- this.mConnections.remove(connection.getLoginUser().getAddress().getScreenName());
-
}
public ImConnectionAdapter findConnection(String localAddress) {
View
10 src/info/guardianproject/otr/app/im/plugin/xmpp/XmppConnection.java
@@ -173,7 +173,8 @@ public void join() {
mExecutor = null;
// This will send us an interrupt, which we will ignore. We will terminate
// anyway after the caller is done. This also drains the executor queue.
- executor.shutdownNow();
+ if (executor != null)
+ executor.shutdownNow();
}
public void sendPacket(final org.jivesoftware.smack.packet.Packet packet) {
@@ -426,7 +427,7 @@ public void initConnection(MyXMPPConnection connection, Contact user, int state)
private void initConnection(String userName, final String password,
Imps.ProviderSettings.QueryMap providerSettings) throws Exception {
-// android.os.Debug.waitForDebugger();
+ android.os.Debug.waitForDebugger();
boolean allowPlainAuth = providerSettings.getAllowPlainAuth();
boolean requireTls = providerSettings.getRequireTls();
@@ -461,7 +462,10 @@ private void initConnection(String userName, final String password,
debug(TAG, "(DNS SRV) resolving: "+domain);
DNSUtil.HostAddress srvHost = DNSUtil.resolveXMPPDomain(domain);
server = srvHost.getHost();
- //serverPort = srvHost.getPort(); //ignore port right now, as we are always a client
+ if (serverPort <= 0) {
+ // If user did not override port, use port from SRV record
+ serverPort = srvHost.getPort();
+ }
debug(TAG, "(DNS SRV) resolved: "+domain+"=" + server + ":" + serverPort);
}
View
16 src/info/guardianproject/util/DNSUtil.java
@@ -128,18 +128,14 @@ public static HostAddress resolveXMPPDomain(String domain) {
}
- if (result == null) {
- result = resolveSRV("_xmpp-server._tcp." + domain);
- }
-
-
- if (result == null) {
+ if (result != null) {
+ // Add item to cache.
+ synchronized (ccache) {
+ ccache.put(domain, result);
@n8fr8
n8fr8 added a note

how long does this cache last?

@devrandom Owner

10 minutes. It looks like xbill has its own cache too, not sure why there are multiple cache levels. We should consider if this level is really needed.

In any case, this change only eliminates caching negative results (i.e. storing new HostAddress(domain, 5222) when result = null).

@devrandom Owner

Oh, when I say "negative results", this includes the case where DNS server times out, network issues, etc. .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ } else {
result = new HostAddress(domain, 5222);
}
- // Add item to cache.
- synchronized (ccache) {
- ccache.put(domain, result);
- }
return result;
}
@n8fr8

how long does this cache last?

@devrandom

10 minutes. It looks like xbill has its own cache too, not sure why there are multiple cache levels. We should consider if this level is really needed.

In any case, this change only eliminates caching negative results (i.e. storing new HostAddress(domain, 5222) when result = null).

@devrandom

Oh, when I say "negative results", this includes the case where DNS server times out, network issues, etc. .

Please sign in to comment.
Something went wrong with that request. Please try again.