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");
|
||||
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);
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
|
@ -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:
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
Reference in New Issue
Block a user