From f1c4a859917f5474a78e6edcba08599cb2b814e5 Mon Sep 17 00:00:00 2001 From: sponge <sponge@mail.i2p> Date: Mon, 6 Oct 2008 09:28:59 +0000 Subject: [PATCH] Code cleanup in I2PSocketManagerFull and I2PServerSocketFull BUGFIX ConnectionHandler had a comparason bug that caused it to block when infact it was asked NOT to block --- .../src/net/i2p/client/streaming/ConnectionHandler.java | 6 +++++- .../src/net/i2p/client/streaming/I2PServerSocketFull.java | 2 -- .../src/net/i2p/client/streaming/I2PSocketManagerFull.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/streaming/java/src/net/i2p/client/streaming/ConnectionHandler.java b/apps/streaming/java/src/net/i2p/client/streaming/ConnectionHandler.java index 4960f1a228..972b08139f 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/ConnectionHandler.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/ConnectionHandler.java @@ -95,7 +95,11 @@ class ConnectionHandler { try { _synQueue.wait(); } catch (InterruptedException ie) {} } else { long remaining = expiration - _context.clock().now(); - if (remaining < 0) +// BUGFIX +// The specified amount of real time has elapsed, more or less. +// If timeout is zero, however, then real time is not taken into consideration +// and the thread simply waits until notified. + if (remaining < 1) break; try { _synQueue.wait(remaining); } catch (InterruptedException ie) {} } diff --git a/apps/streaming/java/src/net/i2p/client/streaming/I2PServerSocketFull.java b/apps/streaming/java/src/net/i2p/client/streaming/I2PServerSocketFull.java index 6b68054d19..55070125c8 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/I2PServerSocketFull.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/I2PServerSocketFull.java @@ -1,8 +1,6 @@ package net.i2p.client.streaming; import java.net.SocketTimeoutException; -import java.util.logging.Level; -import java.util.logging.Logger; import net.i2p.I2PException; /** diff --git a/apps/streaming/java/src/net/i2p/client/streaming/I2PSocketManagerFull.java b/apps/streaming/java/src/net/i2p/client/streaming/I2PSocketManagerFull.java index a33aa394a8..c647741b59 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/I2PSocketManagerFull.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/I2PSocketManagerFull.java @@ -128,8 +128,8 @@ public class I2PSocketManagerFull implements I2PSocketManager { return sock; } else { if(_connectionManager.MgetSoTimeout() == -1) { - return null; - } + return null; + } throw new SocketTimeoutException("I2PSocket timed out"); } } -- GitLab