From b99c4f55163e9c4ac6b123f0e8383b9b9072073b Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 20 Sep 2011 16:02:43 -0700 Subject: Revert the change to DNS_TTL and fix the renewer's TTL In a previous change, DNSConstants.DNS_TTL had been changed to reduce the TTL of mDNS services advertised by the A@H broker. Instead of changing this for all users of JmDNS, A@H will use the DNSStateTask.setDefaultTTL internal API to control the TTL. Also, patch the Renewer so that the renewal interval is based on the task's own TTL instead of the hardcoded TTL in DNSConstants. Change-Id: I9f42b98e8088267b38d380edfd8b2e737d00414e --- src/javax/jmdns/impl/constants/DNSConstants.java | 4 ++-- src/javax/jmdns/impl/tasks/state/Renewer.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/javax') diff --git a/src/javax/jmdns/impl/constants/DNSConstants.java b/src/javax/jmdns/impl/constants/DNSConstants.java index b79400b..2704f94 100644 --- a/src/javax/jmdns/impl/constants/DNSConstants.java +++ b/src/javax/jmdns/impl/constants/DNSConstants.java @@ -18,8 +18,8 @@ public final class DNSConstants { public static final int MDNS_PORT = Integer.parseInt(System.getProperty("net.mdns.port", "5353")); public static final int DNS_PORT = 53; - // DNS Records Expiration Time in Seconds - public static final int DNS_TTL = 25; + // One hour expiration time + public static final int DNS_TTL = 60 * 60; public static final int MAX_MSG_TYPICAL = 1460; public static final int MAX_MSG_ABSOLUTE = 8972; diff --git a/src/javax/jmdns/impl/tasks/state/Renewer.java b/src/javax/jmdns/impl/tasks/state/Renewer.java index 1c638d4..f79ee12 100644 --- a/src/javax/jmdns/impl/tasks/state/Renewer.java +++ b/src/javax/jmdns/impl/tasks/state/Renewer.java @@ -54,7 +54,10 @@ public class Renewer extends DNSStateTask { @Override public void start(Timer timer) { if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) { - timer.schedule(this, DNSConstants.ANNOUNCED_RENEWAL_TTL_INTERVAL, DNSConstants.ANNOUNCED_RENEWAL_TTL_INTERVAL); + // BEGIN android-changed + // Schedule the renewer based on this task's TTL, not the default TTL + timer.schedule(this, getTTL() * 500, getTTL() * 500); + // END android-changed } } -- cgit v1.2.3