diff --git a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java index 503760ed17f7193e369e104901cadc05e596e17d..3beed8c8fc01060dc5b10af4f16e93bca04e6a15 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/Connection.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/Connection.java @@ -126,6 +126,7 @@ public class Connection { _isInbound = false; _updatedShareOpts = false; _connectionEvent = new ConEvent(); + _hardDisconnected = false; _randomWait = _context.random().nextInt(10*1000); // just do this once to reduce usage _context.statManager().createRateStat("stream.con.windowSizeAtCongestion", "How large was our send window when we send a dup?", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.chokeSizeBegin", "How many messages were outstanding when we started to choke?", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); @@ -154,7 +155,7 @@ public class Connection { * @return true if the packet should be sent */ boolean packetSendChoke(long timeoutMs) { - if (false) return true; + // if (false) return true; // <--- what the fuck?? long start = _context.clock().now(); long writeExpire = start + timeoutMs; boolean started = false; @@ -168,9 +169,9 @@ public class Connection { // no need to wait until the other side has ACKed us before sending the first few wsize // packets through - // if (!_connected) - // return false; - + // Incorrect assumption, the constructor defaults _connected to true --Sponge + if (!_connected) + return false; started = true; if ( (_outboundPackets.size() >= _options.getWindowSize()) || (_activeResends > 0) || (_lastSendId - _highestAckedThrough > _options.getWindowSize()) ) { @@ -186,12 +187,12 @@ public class Connection { if (_log.shouldLog(Log.DEBUG)) _log.debug("Outbound window is full (" + _outboundPackets.size() + "/" + _options.getWindowSize() + "/" + _activeResends + "), waiting " + timeLeft); - try { _outboundPackets.wait(timeLeft); } catch (InterruptedException ie) {} + try { _outboundPackets.wait(Math.min(timeLeft,250l)); } catch (InterruptedException ie) {} } else { if (_log.shouldLog(Log.DEBUG)) _log.debug("Outbound window is full (" + _outboundPackets.size() + "/" + _activeResends + "), waiting indefinitely"); - try { _outboundPackets.wait(10*1000); } catch (InterruptedException ie) {} + try { _outboundPackets.wait(250); } catch (InterruptedException ie) {} //10*1000 } } else { _context.statManager().addRateData("stream.chokeSizeEnd", _outboundPackets.size(), _context.clock().now() - start); @@ -494,7 +495,6 @@ public class Connection { synchronized (_connectLock) { _connectLock.notifyAll(); } if (_log.shouldLog(Log.DEBUG)) _log.debug("Disconnecting " + toString(), new Exception("discon")); - if (!cleanDisconnect) { _hardDisconnected = true; if (_log.shouldLog(Log.WARN)) @@ -1017,7 +1017,6 @@ public class Connection { /** * Coordinate the resends of a given packet - * */ public class ResendPacketEvent extends SimpleTimer2.TimedEvent { private PacketLocal _packet;