Files
i2p.i2p/apps/streaming/java/src/net/i2p/client/streaming/SchedulerConnectedBulk.java
jrandom 21f13dba43 2005-02-20 jrandom
* Allow the streaming lib resend frequency to drop down to 20s as the
      minimum, so that up to 2 retries can get sent on an http request.
    * Add further limits to failsafe tunnels.
    * Keep exploratory and client tunnel testing and building stats separate.
    * Only use the 60s period for throttling tunnel requests due to transient
      network overload.
    * Rebuild tunnels earlier (1-3m before expiration, by default)
    * Cache the next hop's routerInfo for participating tunnels so that the
      tunnel participation doesn't depend on the netDb.
    * Fixed a long standing bug in the streaming lib where we wouldn't always
      unchoke messages when the window size grows.
    * Make sure the window size never reaches 0 (duh)
2005-02-21 18:02:14 +00:00

67 lines
2.3 KiB
Java

package net.i2p.client.streaming;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
/**
* <p>Scheduler used for after our SYN has been sent and ACKed but one
* (or more) sides haven't closed the stream yet. In addition, the
* stream must be using the BULK profile, rather than the INTERACTIVE
* profile.</p>
*
* <h2>Entry conditions:</h2><ul>
* <li>Packets sent and ACKs received.</li>
* <li>At least one direction is not closed</li>
* </ul>
*
* <h2>Events:</h2><ul>
* <li>Packets received (which may or may not ACK the ones sent)</li>
* <li>Message flush (explicitly, through a full buffer, or stream closure)</li>
* <li>RESET received</li>
* <li>Message sending fails (error talking to the session)</li>
* <li>Message sending fails (too many resends)</li>
* </ul>
*
* <h2>Next states:</h2>
* <li>{@link SchedulerClosing closing} - after both sending and receiving a CLOSE</li>
* <li>{@link SchedulerClosed closed} - after both sending and receiving ACKs on the CLOSE</li>
* <li>{@link SchedulerDead dead} - after sending or receiving a RESET</li>
* </ul>
*
*/
class SchedulerConnectedBulk extends SchedulerImpl {
private Log _log;
public SchedulerConnectedBulk(I2PAppContext ctx) {
super(ctx);
_log = ctx.logManager().getLog(SchedulerConnectedBulk.class);
}
public boolean accept(Connection con) {
boolean ok = (con != null) &&
(con.getHighestAckedThrough() >= 0) &&
(con.getOptions().getProfile() == ConnectionOptions.PROFILE_BULK) &&
(!con.getResetReceived()) &&
( (con.getCloseSentOn() <= 0) || (con.getCloseReceivedOn() <= 0) );
if (!ok) {
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("con: " + con + " closeSentOn: " + con.getCloseSentOn()
// + " closeReceivedOn: " + con.getCloseReceivedOn());
}
return ok;
}
public void eventOccurred(Connection con) {
if (con.getNextSendTime() <= 0)
return;
long timeTillSend = con.getNextSendTime() - _context.clock().now();
if (timeTillSend <= 0) {
con.setNextSendTime(-1);
con.sendAvailable();
} else {
reschedule(timeTillSend, con);
}
}
}