2004-10-05 jrandom

* Don't go into a fast busy if an I2PTunnel 'server' is explicitly killed
      (thanks mule!)
    * Handle some more error conditions regarding abruptly closing sockets
      (thanks Jonva!)
This commit is contained in:
jrandom
2004-10-05 15:38:37 +00:00
committed by zzz
parent 6251d22c6e
commit 64bcfd09ec
7 changed files with 38 additions and 10 deletions

View File

@ -148,6 +148,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
I2PServerSocket i2pss = sockMgr.getServerSocket();
while (true) {
I2PSocket i2ps = i2pss.accept();
if (i2ps == null) throw new I2PException("I2PServerSocket closed");
I2PThread t = new I2PThread(new Handler(i2ps));
t.start();
}

View File

@ -1,4 +1,10 @@
$Id: history.txt,v 1.31 2004/10/03 15:48:43 jrandom Exp $
$Id: history.txt,v 1.32 2004/10/04 12:30:23 jrandom Exp $
2004-10-05 jrandom
* Don't go into a fast busy if an I2PTunnel 'server' is explicitly killed
(thanks mule!)
* Handle some more error conditions regarding abruptly closing sockets
(thanks Jonva!)
2004-10-04 jrandom
* Update the shitlist to reject a peer for an exponentially increasing

View File

@ -43,7 +43,20 @@ public class I2NPMessageHandler {
int type = (int)DataHelper.readLong(in, 1);
_lastReadBegin = System.currentTimeMillis();
I2NPMessage msg = createMessage(in, type);
try {
msg.readBytes(in, type);
} catch (IOException ioe) {
throw ioe;
} catch (I2NPMessageException ime) {
throw ime;
} catch (DataFormatException dfe) {
throw dfe;
} catch (Exception e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error reading the stream", e);
throw new IOException("Unknown error reading the " + msg.getClass().getName()
+ ": " + e.getMessage());
}
_lastReadEnd = System.currentTimeMillis();
return msg;
} catch (DataFormatException dfe) {

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.41 $ $Date: 2004/10/03 15:48:43 $";
public final static String ID = "$Revision: 1.42 $ $Date: 2004/10/04 12:30:23 $";
public final static String VERSION = "0.4.1.1";
public final static long BUILD = 7;
public final static long BUILD = 8;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -88,16 +88,21 @@ public class Shitlist {
}
public void unshitlistRouter(Hash peer) {
unshitlistRouter(peer, true);
}
private void unshitlistRouter(Hash peer, boolean realUnshitlist) {
if (peer == null) return;
_log.info("Unshitlisting router " + peer.toBase64());
synchronized (_shitlist) {
_shitlist.remove(peer);
_shitlistCause.remove(peer);
}
if (realUnshitlist) {
PeerProfile prof = _context.profileOrganizer().getProfile(peer);
if (prof != null)
prof.unshitlist();
}
}
public boolean isShitlisted(Hash peer) {
Date shitlistDate = null;
@ -110,7 +115,7 @@ public class Shitlist {
if (shitlistDate.getTime() > _context.clock().now()) {
return true;
} else {
unshitlistRouter(peer);
unshitlistRouter(peer, false);
return false;
}
}
@ -133,7 +138,7 @@ public class Shitlist {
Hash key = (Hash)iter.next();
Date shitDate = (Date)shitlist.get(key);
if (shitDate.getTime() < limit) {
unshitlistRouter(key);
unshitlistRouter(key, false);
}
}
}

View File

@ -104,7 +104,7 @@ public class ConnectionBuilder {
try {
return doEstablishConnection();
} catch (Exception e) { // catchall in case the timeout gets us flat footed
_log.error("Error connecting", e);
fail("Error connecting", e);
return null;
}
}

View File

@ -47,6 +47,8 @@ class ConnectionRunner implements Runnable {
if (msg == null) {
if (_keepRunning)
_log.error("next message is null but we should keep running?");
_con.closeConnection();
return;
} else {
sendMessage(msg);
}
@ -88,6 +90,7 @@ class ConnectionRunner implements Runnable {
} catch (IOException ioe) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error writing out the message", ioe);
_con.closeConnection();
}
_con.sent(msg, ok, after - before);
}