summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@qadesh.matthew.ath.cx>2009-11-01 13:48:51 +0000
committerMatthew Johnson <mjj29@qadesh.matthew.ath.cx>2009-11-01 13:48:51 +0000
commit94883c197697e54be33f3255f93f47d04d2223a5 (patch)
tree13c0a09102a899cceb560a91cc9d0cec960de5d1
parentd49879de16c25757e4d6be0a5338f062c069bedb (diff)
fix tcp timestamp issues
-rw-r--r--Makefile11
-rw-r--r--changelog3
-rw-r--r--org/freedesktop/dbus/Transport.java29
3 files changed, 32 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index e2afa71..65bff86 100644
--- a/Makefile
+++ b/Makefile
@@ -189,6 +189,17 @@ low-level: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar testbin/DBu
$(MAKE) DBUS_JAVA_FLOATS=true low-level-run ;\
kill $$(cat pid))
+checktcp: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar testbin/DBusDaemon dbus.jar dbus-java-bin-$(VERSION).jar dbus-bin.jar
+ ( PASS=false; \
+ testbin/DBusDaemon --tcp --addressfile address --pidfile pid 2> server.log&\
+ sleep 1; \
+ export DBUS_SESSION_BUS_ADDRESS=$$(cat address) ;\
+ dbus-monitor >> monitor.log &\
+ if $(MAKE) DBUS_JAVA_FLOATS=true DEBUG=$(DEBUG) testrun 2>&1 | tee client.log; then export PASS=true; fi ; \
+ kill $$(cat pid) ; \
+ if [ "$$PASS" = "true" ]; then exit 0; else exit 1; fi )
+
+
check: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar testbin/DBusDaemon dbus.jar dbus-java-bin-$(VERSION).jar dbus-bin.jar
( PASS=false; \
testbin/DBusDaemon --addressfile address --pidfile pid 2> server.log&\
diff --git a/changelog b/changelog
index 6f8ee5b..6406545 100644
--- a/changelog
+++ b/changelog
@@ -11,6 +11,9 @@ Version 2.6.1:
* Make MessageReader/Writer use Buffered streams to try and improve
performance
* Support reading session bus address from file in $HOME
+ * Fix TCP cookie timestamp problems (Report/fix from Johannes Felten
+ <johannesfelten -at- googlemail -dot- com>)
+
Version 2.6:
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java
index 7c289f8..ccde1e9 100644
--- a/org/freedesktop/dbus/Transport.java
+++ b/org/freedesktop/dbus/Transport.java
@@ -109,9 +109,13 @@ public class Transport
col.setDecomposition(Collator.FULL_DECOMPOSITION);
col.setStrength(Collator.PRIMARY);
}
- public static final int LOCK_TIMEOUT = 1000;
- public static final int COOKIE_TIMEOUT = 120;
+ public static final int LOCK_TIMEOUT = 1000;
+ public static final int NEW_KEY_TIMEOUT_SECONDS = 60 * 5;
+ public static final int EXPIRE_KEYS_TIMEOUT_SECONDS = NEW_KEY_TIMEOUT_SECONDS + (60 * 2);
+ public static final int MAX_TIME_TRAVEL_SECONDS = 60 * 5;
+ public static final int COOKIE_TIMEOUT = 240;
public static final String COOKIE_CONTEXT = "org_freedesktop_java";
+
private String findCookie(String context, String ID) throws IOException
{
String homedir = System.getProperty("user.home");
@@ -119,15 +123,18 @@ public class Transport
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
String s = null;
String cookie = null;
- long timestamp = System.currentTimeMillis()/1000;
- while (null != (s = r.readLine())) {
- String[] line = s.split(" ");
- long time = Long.parseLong(line[1]);
- if (line[0].equals(ID) && (timestamp - time) < COOKIE_TIMEOUT) {
- cookie = line[2];
- break;
- }
- }
+ long now = System.currentTimeMillis()/1000;
+ while (null != (s = r.readLine())) {
+ String[] line = s.split(" ");
+ long timestamp = Long.parseLong(line[1]);
+ if (line[0].equals(ID) && (! (timestamp < 0 ||
+ (now + MAX_TIME_TRAVEL_SECONDS) < timestamp ||
+ (now - EXPIRE_KEYS_TIMEOUT_SECONDS) > timestamp))) {
+ cookie = line[2];
+ break;
+ }
+ }
+ r.close();
return cookie;
}
private void addCookie(String context, String ID, long timestamp, String cookie) throws IOException