2005-12-27 jrandom

* Add a new Status: line on the router console - "ERR-ClockSkew", in case
      the clock is too skewed to do anything useful (check the year and month,
      not just the hour and minute).
    * Fixed the read/write timeouts in the streaming lib (so that it actually
      honors them now)
    * Minor I2PSnark cleanups (no read timeout, more careful shutdown and
      torrent closing)
    * Handle an oddball tunnel creation failure (thanks Xunk)
This commit is contained in:
jrandom
2005-12-27 13:20:50 +00:00
committed by zzz
parent 9b7e5d1817
commit 1d0d0d9c69
11 changed files with 63 additions and 22 deletions

View File

@ -96,8 +96,8 @@ public class I2PSnarkUtil {
opts.setProperty("i2p.streaming.inactivityAction", "1");
if (opts.getProperty("i2p.streaming.writeTimeout") == null)
opts.setProperty("i2p.streaming.writeTimeout", "90000");
if (opts.getProperty("i2p.streaming.readTimeout") == null)
opts.setProperty("i2p.streaming.readTimeout", "90000");
//if (opts.getProperty("i2p.streaming.readTimeout") == null)
// opts.setProperty("i2p.streaming.readTimeout", "120000");
_manager = I2PSocketManagerFactory.createManager(_i2cpHost, _i2cpPort, opts);
}
return (_manager != null);

View File

@ -411,15 +411,23 @@ public class Snark
*/
public void stopTorrent() {
stopped = true;
trackerclient.halt();
coordinator.halt();
try {
storage.close();
} catch (IOException ioe) {
System.out.println("Error closing " + torrent);
ioe.printStackTrace();
TrackerClient tc = trackerclient;
if (tc != null)
tc.halt();
PeerCoordinator pc = coordinator;
if (pc != null)
pc.halt();
Storage st = storage;
if (st != null) {
try {
storage.close();
} catch (IOException ioe) {
System.out.println("Error closing " + torrent);
ioe.printStackTrace();
}
}
PeerCoordinatorSet.instance().remove(coordinator);
if (pc != null)
PeerCoordinatorSet.instance().remove(pc);
}
static Snark parseArguments(String[] args)

View File

@ -199,7 +199,9 @@ public class I2PSnarkServlet extends HttpServlet {
List files = snark.meta.getFiles();
String dataFile = snark.meta.getName();
for (int i = 0; files != null && i < files.size(); i++) {
File df = new File(_manager.getDataDir(), (String)files.get(i));
// multifile torrents have the getFiles() return lists of lists of filenames, but
// each of those lists just contain a single file afaict...
File df = new File(_manager.getDataDir(), files.get(i).toString());
boolean deleted = FileUtil.rmdir(df, false);
if (deleted)
_manager.addMessage("Data dir deleted: " + df.getAbsolutePath());

View File

@ -110,6 +110,9 @@ public class SummaryHelper {
public int getAllPeers() { return _context.netDb().getKnownRouters(); }
public String getReachability() {
if (!_context.clock().getUpdatedSuccessfully())
return "ERR-ClockSkew";
int status = _context.commSystem().getReachabilityStatus();
switch (status) {
case CommSystemFacade.STATUS_OK:

View File

@ -95,6 +95,8 @@ public class Connection {
_outboundQueue = queue;
_handler = handler;
_options = (opts != null ? opts : new ConnectionOptions());
_outputStream.setWriteTimeout((int)_options.getWriteTimeout());
_inputStream.setReadTimeout((int)_options.getReadTimeout());
_lastSendId = -1;
_nextSendTime = -1;
_ackedPackets = 0;
@ -145,8 +147,8 @@ public class Connection {
*/
boolean packetSendChoke(long timeoutMs) {
if (false) return true;
long writeExpire = timeoutMs;
long start = _context.clock().now();
long writeExpire = start + timeoutMs;
boolean started = false;
while (true) {
long timeLeft = writeExpire - _context.clock().now();

View File

@ -90,6 +90,7 @@ public class I2PSocketFull implements I2PSocket {
Connection c = _connection;
if (c == null) return;
c.getInputStream().setReadTimeout((int)ms);
c.getOptions().setReadTimeout(ms);
}
@ -106,8 +107,11 @@ public class I2PSocketFull implements I2PSocket {
}
void destroy() {
Connection c = _connection;
_connection = null;
_listener = null;
if (c != null)
c.disconnectComplete();
}
public String toString() {
Connection c = _connection;

View File

@ -405,6 +405,10 @@ public class MessageOutputStream extends OutputStream {
void destroy() {
_dataReceiver = null;
synchronized (_dataLock) {
_closed = true;
_dataLock.notifyAll();
}
}
/** Define a component to receive data flushed from this stream */

View File

@ -82,7 +82,11 @@ public class Clock implements Timestamper.UpdateListener {
}
}
if (_alreadyChanged) {
getLog().log(Log.CRIT, "Updating clock offset to " + offsetMs + "ms from " + _offset + "ms");
if (delta > 15*1000)
getLog().log(Log.CRIT, "Updating clock offset to " + offsetMs + "ms from " + _offset + "ms");
else if (getLog().shouldLog(Log.INFO))
getLog().info("Updating clock offset to " + offsetMs + "ms from " + _offset + "ms");
if (!_statCreated)
_context.statManager().createRateStat("clock.skew", "How far is the already adjusted clock being skewed?", "Clock", new long[] { 10*60*1000, 3*60*60*1000, 24*60*60*60 });
_statCreated = true;
@ -98,6 +102,8 @@ public class Clock implements Timestamper.UpdateListener {
public long getOffset() {
return _offset;
}
public boolean getUpdatedSuccessfully() { return _alreadyChanged; }
public void setNow(long realTime) {
long diff = realTime - System.currentTimeMillis();

View File

@ -1,4 +1,14 @@
$Id: history.txt,v 1.369 2005/12/22 07:49:09 jrandom Exp $
$Id: history.txt,v 1.370 2005/12/26 23:20:29 complication Exp $
2005-12-27 jrandom
* Add a new Status: line on the router console - "ERR-ClockSkew", in case
the clock is too skewed to do anything useful (check the year and month,
not just the hour and minute).
* Fixed the read/write timeouts in the streaming lib (so that it actually
honors them now)
* Minor I2PSnark cleanups (no read timeout, more careful shutdown and
torrent closing)
* Handle an oddball tunnel creation failure (thanks Xunk)
2005-12-26 Complication
* Fix some integer typecasting in I2PSnark (caused >2GB torrents to fail)

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.317 $ $Date: 2005/12/22 07:49:09 $";
public final static String ID = "$Revision: 1.318 $ $Date: 2005/12/26 23:20:30 $";
public final static String VERSION = "0.6.1.8";
public final static long BUILD = 1;
public final static long BUILD = 2;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -252,15 +252,17 @@ public class RequestTunnelJob extends JobImpl {
default:
// ignore
}
// penalize peer based on their bitchiness level
getContext().profileManager().tunnelRejected(_currentPeer.getIdentity().calculateHash(),
getContext().clock().now() - _lastSendTime,
howBad);
if (_currentPeer != null)
// penalize peer based on their bitchiness level
getContext().profileManager().tunnelRejected(_currentPeer.getIdentity().calculateHash(),
getContext().clock().now() - _lastSendTime,
howBad);
}
if (_log.shouldLog(Log.INFO))
_log.info("Tunnel request failed w/ cause=" + howBad + " for peer "
+ _currentPeer.getIdentity().calculateHash().toBase64().substring(0,4));
+ (_currentPeer == null ? "[unknown]" :
_currentPeer.getIdentity().calculateHash().toBase64().substring(0,4)));
tunnelFail();
}