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:
@ -96,8 +96,8 @@ public class I2PSnarkUtil {
|
|||||||
opts.setProperty("i2p.streaming.inactivityAction", "1");
|
opts.setProperty("i2p.streaming.inactivityAction", "1");
|
||||||
if (opts.getProperty("i2p.streaming.writeTimeout") == null)
|
if (opts.getProperty("i2p.streaming.writeTimeout") == null)
|
||||||
opts.setProperty("i2p.streaming.writeTimeout", "90000");
|
opts.setProperty("i2p.streaming.writeTimeout", "90000");
|
||||||
if (opts.getProperty("i2p.streaming.readTimeout") == null)
|
//if (opts.getProperty("i2p.streaming.readTimeout") == null)
|
||||||
opts.setProperty("i2p.streaming.readTimeout", "90000");
|
// opts.setProperty("i2p.streaming.readTimeout", "120000");
|
||||||
_manager = I2PSocketManagerFactory.createManager(_i2cpHost, _i2cpPort, opts);
|
_manager = I2PSocketManagerFactory.createManager(_i2cpHost, _i2cpPort, opts);
|
||||||
}
|
}
|
||||||
return (_manager != null);
|
return (_manager != null);
|
||||||
|
@ -411,15 +411,23 @@ public class Snark
|
|||||||
*/
|
*/
|
||||||
public void stopTorrent() {
|
public void stopTorrent() {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
trackerclient.halt();
|
TrackerClient tc = trackerclient;
|
||||||
coordinator.halt();
|
if (tc != null)
|
||||||
try {
|
tc.halt();
|
||||||
storage.close();
|
PeerCoordinator pc = coordinator;
|
||||||
} catch (IOException ioe) {
|
if (pc != null)
|
||||||
System.out.println("Error closing " + torrent);
|
pc.halt();
|
||||||
ioe.printStackTrace();
|
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)
|
static Snark parseArguments(String[] args)
|
||||||
|
@ -199,7 +199,9 @@ public class I2PSnarkServlet extends HttpServlet {
|
|||||||
List files = snark.meta.getFiles();
|
List files = snark.meta.getFiles();
|
||||||
String dataFile = snark.meta.getName();
|
String dataFile = snark.meta.getName();
|
||||||
for (int i = 0; files != null && i < files.size(); i++) {
|
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);
|
boolean deleted = FileUtil.rmdir(df, false);
|
||||||
if (deleted)
|
if (deleted)
|
||||||
_manager.addMessage("Data dir deleted: " + df.getAbsolutePath());
|
_manager.addMessage("Data dir deleted: " + df.getAbsolutePath());
|
||||||
|
@ -110,6 +110,9 @@ public class SummaryHelper {
|
|||||||
public int getAllPeers() { return _context.netDb().getKnownRouters(); }
|
public int getAllPeers() { return _context.netDb().getKnownRouters(); }
|
||||||
|
|
||||||
public String getReachability() {
|
public String getReachability() {
|
||||||
|
if (!_context.clock().getUpdatedSuccessfully())
|
||||||
|
return "ERR-ClockSkew";
|
||||||
|
|
||||||
int status = _context.commSystem().getReachabilityStatus();
|
int status = _context.commSystem().getReachabilityStatus();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case CommSystemFacade.STATUS_OK:
|
case CommSystemFacade.STATUS_OK:
|
||||||
|
@ -95,6 +95,8 @@ public class Connection {
|
|||||||
_outboundQueue = queue;
|
_outboundQueue = queue;
|
||||||
_handler = handler;
|
_handler = handler;
|
||||||
_options = (opts != null ? opts : new ConnectionOptions());
|
_options = (opts != null ? opts : new ConnectionOptions());
|
||||||
|
_outputStream.setWriteTimeout((int)_options.getWriteTimeout());
|
||||||
|
_inputStream.setReadTimeout((int)_options.getReadTimeout());
|
||||||
_lastSendId = -1;
|
_lastSendId = -1;
|
||||||
_nextSendTime = -1;
|
_nextSendTime = -1;
|
||||||
_ackedPackets = 0;
|
_ackedPackets = 0;
|
||||||
@ -145,8 +147,8 @@ public class Connection {
|
|||||||
*/
|
*/
|
||||||
boolean packetSendChoke(long timeoutMs) {
|
boolean packetSendChoke(long timeoutMs) {
|
||||||
if (false) return true;
|
if (false) return true;
|
||||||
long writeExpire = timeoutMs;
|
|
||||||
long start = _context.clock().now();
|
long start = _context.clock().now();
|
||||||
|
long writeExpire = start + timeoutMs;
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
long timeLeft = writeExpire - _context.clock().now();
|
long timeLeft = writeExpire - _context.clock().now();
|
||||||
|
@ -90,6 +90,7 @@ public class I2PSocketFull implements I2PSocket {
|
|||||||
Connection c = _connection;
|
Connection c = _connection;
|
||||||
if (c == null) return;
|
if (c == null) return;
|
||||||
|
|
||||||
|
c.getInputStream().setReadTimeout((int)ms);
|
||||||
c.getOptions().setReadTimeout(ms);
|
c.getOptions().setReadTimeout(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +107,11 @@ public class I2PSocketFull implements I2PSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
|
Connection c = _connection;
|
||||||
_connection = null;
|
_connection = null;
|
||||||
_listener = null;
|
_listener = null;
|
||||||
|
if (c != null)
|
||||||
|
c.disconnectComplete();
|
||||||
}
|
}
|
||||||
public String toString() {
|
public String toString() {
|
||||||
Connection c = _connection;
|
Connection c = _connection;
|
||||||
|
@ -405,6 +405,10 @@ public class MessageOutputStream extends OutputStream {
|
|||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
_dataReceiver = null;
|
_dataReceiver = null;
|
||||||
|
synchronized (_dataLock) {
|
||||||
|
_closed = true;
|
||||||
|
_dataLock.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Define a component to receive data flushed from this stream */
|
/** Define a component to receive data flushed from this stream */
|
||||||
|
@ -82,7 +82,11 @@ public class Clock implements Timestamper.UpdateListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_alreadyChanged) {
|
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)
|
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 });
|
_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;
|
_statCreated = true;
|
||||||
@ -99,6 +103,8 @@ public class Clock implements Timestamper.UpdateListener {
|
|||||||
return _offset;
|
return _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getUpdatedSuccessfully() { return _alreadyChanged; }
|
||||||
|
|
||||||
public void setNow(long realTime) {
|
public void setNow(long realTime) {
|
||||||
long diff = realTime - System.currentTimeMillis();
|
long diff = realTime - System.currentTimeMillis();
|
||||||
setOffset(diff);
|
setOffset(diff);
|
||||||
|
12
history.txt
12
history.txt
@ -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
|
2005-12-26 Complication
|
||||||
* Fix some integer typecasting in I2PSnark (caused >2GB torrents to fail)
|
* Fix some integer typecasting in I2PSnark (caused >2GB torrents to fail)
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
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 String VERSION = "0.6.1.8";
|
||||||
public final static long BUILD = 1;
|
public final static long BUILD = 2;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
@ -253,14 +253,16 @@ public class RequestTunnelJob extends JobImpl {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
// penalize peer based on their bitchiness level
|
if (_currentPeer != null)
|
||||||
getContext().profileManager().tunnelRejected(_currentPeer.getIdentity().calculateHash(),
|
// penalize peer based on their bitchiness level
|
||||||
getContext().clock().now() - _lastSendTime,
|
getContext().profileManager().tunnelRejected(_currentPeer.getIdentity().calculateHash(),
|
||||||
howBad);
|
getContext().clock().now() - _lastSendTime,
|
||||||
|
howBad);
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Tunnel request failed w/ cause=" + howBad + " for peer "
|
_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();
|
tunnelFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user