/** * May be called even when already running. May be called to start up again after halt(). */ public synchronized void startAccepting() { stop = false; if (_log.shouldLog(Log.WARN)) _log.warn("ConnectionAcceptor startAccepting new thread? " + (thread == null)); if (thread == null) { thread = new I2PAppThread(this, "I2PSnark acceptor"); thread.setDaemon(true); thread.start(); _cleaner.reschedule(BAD_CLEAN_INTERVAL, false); } }
/** * Will force a fast restransmit on the 3rd call (FAST_RETRANSMIT_THRESHOLD) * but only if it's the lowest unacked (see Connection.ResendPacketEvent) */ public void incrementNACKs() { final int cnt = _nackCount.incrementAndGet(); SimpleTimer2.TimedEvent evt = _resendEvent; if (cnt >= Connection.FAST_RETRANSMIT_THRESHOLD && evt != null && (!_retransmitted) && (_numSends.get() == 1 || _lastSend < _context.clock().now() - 4*1000)) { // Don't fast retx if we recently resent it _retransmitted = true; evt.reschedule(0); // the predicate used to be '+', changing to '-' --zab if (_log.shouldLog(Log.DEBUG)) { final String log = String.format("%s nacks and retransmits. Criteria: nacks=%d, retransmitted=%b,"+ " numSends=%d, lastSend=%d, now=%d", toString(), cnt, _retransmitted, _numSends.get(), _lastSend, _context.clock().now()); _log.debug(log); } } else if (_log.shouldLog(Log.DEBUG)) { final String log = String.format("%s nack but no retransmit. Criteria: nacks=%d, retransmitted=%b,"+ " numSends=%d, lastSend=%d, now=%d", toString(), cnt, _retransmitted, _numSends.get(), _lastSend, _context.clock().now()); _log.debug(log); } } public int getNACKs() { return _nackCount.get(); }
/** * Will force a fast restransmit on the 3rd call (FAST_RETRANSMIT_THRESHOLD) * but only if it's the lowest unacked (see Connection.ResendPacketEvent) */ public void incrementNACKs() { final int cnt = _nackCount.incrementAndGet(); SimpleTimer2.TimedEvent evt = _resendEvent; if (cnt >= Connection.FAST_RETRANSMIT_THRESHOLD && evt != null && (!_retransmitted) && (_numSends.get() == 1 || _lastSend < _context.clock().now() - 4*1000)) { // Don't fast retx if we recently resent it _retransmitted = true; evt.reschedule(0); // the predicate used to be '+', changing to '-' --zab if (_log.shouldLog(Log.DEBUG)) { final String log = String.format("%s nacks and retransmits. Criteria: nacks=%d, retransmitted=%b,"+ " numSends=%d, lastSend=%d, now=%d", toString(), cnt, _retransmitted, _numSends.get(), _lastSend, _context.clock().now()); _log.debug(log); } } else if (_log.shouldLog(Log.DEBUG)) { final String log = String.format("%s nack but no retransmit. Criteria: nacks=%d, retransmitted=%b,"+ " numSends=%d, lastSend=%d, now=%d", toString(), cnt, _retransmitted, _numSends.get(), _lastSend, _context.clock().now()); _log.debug(log); } } public int getNACKs() { return _nackCount.get(); }
/** * Use the earliest of the new time and the old time * May be called from within timeReached(), but schedule() is * better there. * * @param timeoutMs */ public void reschedule(long timeoutMs) { reschedule(timeoutMs, true); }