From 879404f7e0274836b6f25ed2ebd88f0bd67ca79b Mon Sep 17 00:00:00 2001 From: sponge Date: Sat, 11 Apr 2009 13:55:38 +0000 Subject: [PATCH] 2009-04-11 sponge * i2ptunnel janitorial work and fixes on most locks. Some locks still need work, and are marked with LINT in the comment. Just grep for "LINT" to see where the remaining places are. --- .../src/net/i2p/i2ptunnel/BufferLogger.java | 2 +- .../i2p/i2ptunnel/HTTPResponseOutputStream.java | 6 ++++++ .../java/src/net/i2p/i2ptunnel/I2PTunnel.java | 14 +++++++------- .../src/net/i2p/i2ptunnel/I2PTunnelClient.java | 10 +++++----- .../net/i2p/i2ptunnel/I2PTunnelClientBase.java | 14 +++++++------- .../i2p/i2ptunnel/I2PTunnelConnectClient.java | 5 ++--- .../net/i2p/i2ptunnel/I2PTunnelHTTPClient.java | 4 ++-- .../i2ptunnel/I2PTunnelHTTPClientRunner.java | 2 ++ .../net/i2p/i2ptunnel/I2PTunnelHTTPServer.java | 4 ++++ .../net/i2p/i2ptunnel/I2PTunnelIRCClient.java | 6 +++--- .../net/i2p/i2ptunnel/I2PTunnelIRCServer.java | 5 +---- .../src/net/i2p/i2ptunnel/I2PTunnelRunner.java | 4 +++- .../src/net/i2p/i2ptunnel/I2PTunnelServer.java | 14 ++++++-------- .../src/net/i2p/i2ptunnel/I2PTunnelTask.java | 1 + .../java/src/net/i2p/i2ptunnel/I2Ping.java | 5 +++-- .../i2p/i2ptunnel/TunnelControllerGroup.java | 2 +- .../net/i2p/i2ptunnel/socks/ReplyTracker.java | 1 - .../net/i2p/i2ptunnel/socks/SOCKS5Server.java | 2 +- .../net/i2p/i2ptunnel/socks/SOCKSServer.java | 1 - .../net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java | 5 ++--- .../src/net/i2p/i2ptunnel/streamr/Pinger.java | 2 +- .../i2p/i2ptunnel/streamr/StreamrConsumer.java | 3 ++- .../i2p/i2ptunnel/streamr/StreamrProducer.java | 3 ++- .../net/i2p/i2ptunnel/streamr/Subscriber.java | 5 ----- .../java/src/net/i2p/i2ptunnel/udp/I2PSink.java | 2 +- .../net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java | 2 +- .../udpTunnel/I2PTunnelUDPClientBase.java | 17 ++--------------- .../udpTunnel/I2PTunnelUDPServerBase.java | 13 +------------ .../src/net/i2p/i2ptunnel/web/EditBean.java | 1 - history.txt | 5 +++++ .../java/src/net/i2p/router/RouterVersion.java | 2 +- 31 files changed, 73 insertions(+), 89 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java index 29f954fc4..4c3da0898 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java @@ -14,7 +14,7 @@ import net.i2p.util.Log; */ class BufferLogger implements Logging { private final static Log _log = new Log(BufferLogger.class); - private ByteArrayOutputStream _baos; + private ByteArrayOutputStream _baos; // should be final and use a factory. LINT private boolean _ignore; /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/HTTPResponseOutputStream.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/HTTPResponseOutputStream.java index 411b2c442..12940a81b 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/HTTPResponseOutputStream.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/HTTPResponseOutputStream.java @@ -59,13 +59,16 @@ class HTTPResponseOutputStream extends FilterOutputStream { _buf1 = new byte[1]; } + @Override public void write(int c) throws IOException { _buf1[0] = (byte)c; write(_buf1, 0, 1); } + @Override public void write(byte buf[]) throws IOException { write(buf, 0, buf.length); } + @Override public void write(byte buf[], int off, int len) throws IOException { if (_headerWritten) { out.write(buf, off, len); @@ -207,6 +210,7 @@ class HTTPResponseOutputStream extends FilterOutputStream { out.write("\r\n".getBytes()); // end of the headers } + @Override public void close() throws IOException { out.close(); } @@ -303,11 +307,13 @@ class HTTPResponseOutputStream extends FilterOutputStream { return true; } } + @Override public String toString() { return "Read: " + getTotalRead() + " expanded: " + getTotalExpanded() + " remaining: " + getRemaining() + " finished: " + getFinished(); } } + @Override public String toString() { return super.toString() + ": " + _in; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java index b11f954e7..015f5c9c5 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java @@ -75,7 +75,7 @@ public class I2PTunnel implements Logging, EventDispatcher { private static long __tunnelId = 0; private long _tunnelId; private Properties _clientOptions; - private List _sessions; + private final List _sessions; public static final int PACKET_DELAY = 100; @@ -89,7 +89,7 @@ public class I2PTunnel implements Logging, EventDispatcher { private static final String nocli_args[] = { "-nocli", "-die"}; - private List tasks = new ArrayList(); + private final List tasks = new ArrayList(); private int next_task_id = 1; private Set listeners = new HashSet(); @@ -606,9 +606,9 @@ public class I2PTunnel implements Logging, EventDispatcher { */ public void runHttpClient(String args[], Logging l) { if (args.length >= 1 && args.length <= 3) { - int port = -1; + int clientPort = -1; try { - port = Integer.parseInt(args[0]); + clientPort = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe); @@ -642,12 +642,12 @@ public class I2PTunnel implements Logging, EventDispatcher { I2PTunnelTask task; ownDest = !isShared; try { - task = new I2PTunnelHTTPClient(port, l, ownDest, proxy, (EventDispatcher) this, this); + task = new I2PTunnelHTTPClient(clientPort, l, ownDest, proxy, (EventDispatcher) this, this); addtask(task); notifyEvent("httpclientTaskId", Integer.valueOf(task.getId())); } catch (IllegalArgumentException iae) { - _log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ port + "]", iae); - l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]"); + _log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ clientPort + "]", iae); + l.log("Invalid I2PTunnel configuration [" + host + ":" + clientPort + "]"); notifyEvent("httpclientTaskId", Integer.valueOf(-1)); } } else { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java index 502bb28d5..12931f3a2 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java @@ -44,11 +44,11 @@ public class I2PTunnelClient extends I2PTunnelClientBase { while (tok.hasMoreTokens()) { String destination = tok.nextToken(); try { - Destination dest = I2PTunnel.destFromName(destination); - if (dest == null) + Destination destN = I2PTunnel.destFromName(destination); + if (destN == null) l.log("Could not resolve " + destination); else - dests.add(dest); + dests.add(destN); } catch (DataFormatException dfe) { l.log("Bad format parsing \"" + destination + "\""); } @@ -71,10 +71,10 @@ public class I2PTunnelClient extends I2PTunnelClientBase { public long getReadTimeout() { return readTimeout; } protected void clientConnectionRun(Socket s) { - Destination dest = pickDestination(); + Destination destN = pickDestination(); I2PSocket i2ps = null; try { - i2ps = createI2PSocket(dest); + i2ps = createI2PSocket(destN); i2ps.setReadTimeout(readTimeout); new I2PTunnelRunner(s, i2ps, sockLock, null, mySockets); } catch (Exception ex) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index 5b9aa23cb..c4eafde50 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -41,8 +41,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna private static volatile long __clientId = 0; protected long _clientId; - protected Object sockLock = new Object(); // Guards sockMgr and mySockets - protected I2PSocketManager sockMgr; + protected final Object sockLock = new Object(); // Guards sockMgr and mySockets + protected I2PSocketManager sockMgr; // should be final and use a factory. LINT protected List mySockets = new ArrayList(); protected Destination dest = null; @@ -52,20 +52,20 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna private ServerSocket ss; - private Object startLock = new Object(); + private final Object startLock = new Object(); private boolean startRunning = false; - private Object closeLock = new Object(); + // private Object closeLock = new Object(); - private byte[] pubkey; + // private byte[] pubkey; private String handlerName; private String privKeyFile; - private Object conLock = new Object(); + // private Object conLock = new Object(); /** List of Socket for those accept()ed but not yet started up */ - private List _waitingSockets = new ArrayList(); + private List _waitingSockets = new ArrayList(); // should be final and use a factory. LINT /** How many connections will we allow to be in the process of being built at once? */ private int _numConnectionBuilders; /** How long will we allow sockets to sit in the _waitingSockets map before killing them? */ diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java index bf7ebf0a7..d781866d9 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java @@ -17,7 +17,6 @@ import net.i2p.I2PAppContext; import net.i2p.I2PException; import net.i2p.client.streaming.I2PSocket; import net.i2p.client.streaming.I2PSocketOptions; -import net.i2p.data.DataFormatException; import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.util.EventDispatcher; @@ -55,7 +54,7 @@ import net.i2p.util.Log; public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runnable { private static final Log _log = new Log(I2PTunnelConnectClient.class); - private List _proxyList; + private final List _proxyList; private final static byte[] ERR_DESTINATION_UNKNOWN = ("HTTP/1.1 503 Service Unavailable\r\n"+ @@ -116,12 +115,12 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna I2PTunnel tunnel) throws IllegalArgumentException { super(localPort, ownDest, l, notifyThis, "HTTPHandler " + (++__clientId), tunnel); + _proxyList = new ArrayList(); if (waitEventValue("openBaseClientResult").equals("error")) { notifyEvent("openConnectClientResult", "error"); return; } - _proxyList = new ArrayList(); if (wwwProxy != null) { StringTokenizer tok = new StringTokenizer(wwwProxy, ","); while (tok.hasMoreTokens()) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 8e5ef9f4d..93c8e8674 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -50,7 +50,7 @@ import net.i2p.util.Log; public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable { private static final Log _log = new Log(I2PTunnelHTTPClient.class); - private List proxyList; + private final List proxyList; private HashMap addressHelpers = new HashMap(); @@ -145,12 +145,12 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable I2PTunnel tunnel) throws IllegalArgumentException { super(localPort, ownDest, l, notifyThis, "HTTPHandler " + (++__clientId), tunnel); + proxyList = new ArrayList(); if (waitEventValue("openBaseClientResult").equals("error")) { notifyEvent("openHTTPClientResult", "error"); return; } - proxyList = new ArrayList(); if (wwwProxy != null) { StringTokenizer tok = new StringTokenizer(wwwProxy, ","); while (tok.hasMoreTokens()) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientRunner.java index 9ade9021f..6afc940f7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientRunner.java @@ -30,11 +30,13 @@ public class I2PTunnelHTTPClientRunner extends I2PTunnelRunner { _log = I2PAppContext.getGlobalContext().logManager().getLog(I2PTunnelHTTPClientRunner.class); } + @Override protected OutputStream getSocketOut() throws IOException { OutputStream raw = super.getSocketOut(); return new HTTPResponseOutputStream(raw); } + @Override protected void close(OutputStream out, InputStream in, OutputStream i2pout, InputStream i2pin, Socket s, I2PSocket i2ps, Thread t1, Thread t2) throws InterruptedException, IOException { try { i2pin.close(); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index d6cb40a25..d43639cb7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -59,6 +59,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { * Called by the thread pool of I2PSocket handlers * */ + @Override protected void blockingHandle(I2PSocket socket) { long afterAccept = getTunnel().getContext().clock().now(); long afterSocket = -1; @@ -247,7 +248,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { super(o); } + @Override protected boolean shouldCompress() { return true; } + @Override protected void finishHeaders() throws IOException { if (_log.shouldLog(Log.INFO)) _log.info("Including x-i2p-gzip as the content encoding in the response"); @@ -255,6 +258,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { super.finishHeaders(); } + @Override protected void beginProcessing() throws IOException { if (_log.shouldLog(Log.INFO)) _log.info("Beginning compression processing"); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java index 732c222a7..8b6270219 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java @@ -51,11 +51,11 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable while (tok.hasMoreTokens()) { String destination = tok.nextToken(); try { - Destination dest = I2PTunnel.destFromName(destination); - if (dest == null) + Destination destN = I2PTunnel.destFromName(destination); + if (destN == null) l.log("Could not resolve " + destination); else - dests.add(dest); + dests.add(destN); } catch (DataFormatException dfe) { l.log("Bad format parsing \"" + destination + "\""); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java index 7e12aa30a..2e209dbd7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java @@ -3,22 +3,18 @@ package net.i2p.i2ptunnel; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.util.Properties; -import net.i2p.I2PAppContext; import net.i2p.client.streaming.I2PSocket; import net.i2p.crypto.SHA256Generator; -import net.i2p.data.DataFormatException; import net.i2p.data.DataHelper; import net.i2p.data.Destination; import net.i2p.data.Hash; import net.i2p.data.Base32; import net.i2p.util.EventDispatcher; -import net.i2p.util.I2PThread; import net.i2p.util.Log; /** @@ -83,6 +79,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable { this.hostname = opts.getProperty(PROP_HOSTNAME, PROP_HOSTNAME_DEFAULT); } + @Override protected void blockingHandle(I2PSocket socket) { try { // give them 15 seconds to send in the request diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java index f237b97ef..76480a940 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java @@ -36,7 +36,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL private Socket s; private I2PSocket i2ps; - Object slock, finishLock = new Object(); + final Object slock, finishLock = new Object(); boolean finished = false; HashMap ostreams, sockets; byte[] initialI2PData; @@ -114,6 +114,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL protected InputStream getSocketIn() throws IOException { return s.getInputStream(); } protected OutputStream getSocketOut() throws IOException { return s.getOutputStream(); } + @Override public void run() { try { InputStream in = getSocketIn(); @@ -239,6 +240,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL start(); } + @Override public void run() { String from = i2ps.getThisDestination().calculateHash().toBase64().substring(0,6); String to = i2ps.getPeerDestination().calculateHash().toBase64().substring(0,6); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index fa3478c71..76246d7b6 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -18,8 +18,6 @@ import java.util.Properties; import net.i2p.I2PAppContext; import net.i2p.I2PException; -import net.i2p.client.I2PClient; -import net.i2p.client.I2PClientFactory; import net.i2p.client.streaming.I2PServerSocket; import net.i2p.client.streaming.I2PSocket; import net.i2p.client.streaming.I2PSocketManager; @@ -36,8 +34,8 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { protected I2PSocketManager sockMgr; protected I2PServerSocket i2pss; - private Object lock = new Object(); - protected Object slock = new Object(); + private final Object lock = new Object(); + protected final Object slock = new Object(); protected InetAddress remoteHost; protected int remotePort; @@ -203,17 +201,17 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { public void run() { if (shouldUsePool()) { - I2PServerSocket i2pss = sockMgr.getServerSocket(); + I2PServerSocket i2pS_S = sockMgr.getServerSocket(); int handlers = getHandlerCount(); for (int i = 0; i < handlers; i++) { - I2PThread handler = new I2PThread(new Handler(i2pss), "Handle Server " + i); + I2PThread handler = new I2PThread(new Handler(i2pS_S), "Handle Server " + i); handler.start(); } } else { - I2PServerSocket i2pss = sockMgr.getServerSocket(); + I2PServerSocket i2pS_S = sockMgr.getServerSocket(); while (true) { try { - final I2PSocket i2ps = i2pss.accept(); + final I2PSocket i2ps = i2pS_S.accept(); if (i2ps == null) throw new I2PException("I2PServerSocket closed"); new I2PThread(new Runnable() { public void run() { blockingHandle(i2ps); } }).start(); } catch (I2PException ipe) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelTask.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelTask.java index 6aa8ca18f..4a6a0bb66 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelTask.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelTask.java @@ -73,6 +73,7 @@ public abstract class I2PTunnelTask implements EventDispatcher { public void reportAbuse(I2PSession session, int severity) { } + @Override public String toString() { return name; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java index 019bc7826..f57ecd23d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java @@ -37,11 +37,11 @@ public class I2Ping extends I2PTunnelTask implements Runnable { private String command; private long timeout = PING_TIMEOUT; - private Object simulLock = new Object(); + private final Object simulLock = new Object(); private int simulPings = 0; private long lastPingTime = 0; - private Object lock = new Object(), slock = new Object(); + private final Object lock = new Object(), slock = new Object(); //public I2Ping(String cmd, Logging l, // boolean ownDest) { @@ -197,6 +197,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable { start(); } + @Override public void run() { try { Destination dest = I2PTunnel.destFromName(destination); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java index 3b6e76539..16f418be9 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java @@ -40,7 +40,7 @@ public class TunnelControllerGroup { * no more tunnels are using it) * */ - private Map _sessions; + private final Map _sessions; public static TunnelControllerGroup getInstance() { synchronized (TunnelControllerGroup.class) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java index f6a124c95..fbdf2939d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java @@ -1,6 +1,5 @@ package net.i2p.i2ptunnel.socks; -import java.util.concurrent.ConcurrentHashMap; import java.util.Map; import net.i2p.data.Destination; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java index 5e5292607..cc397c414 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java @@ -379,7 +379,7 @@ public class SOCKS5Server extends SOCKSServer { // This isn't really the right place for this, we can't stop the tunnel once it starts. static SOCKSUDPTunnel _tunnel; - static Object _startLock = new Object(); + static final Object _startLock = new Object(); static byte[] dummyIP = new byte[4]; /** * We got a UDP associate command. diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServer.java index 06c3fab55..09e9284de 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSServer.java @@ -9,7 +9,6 @@ package net.i2p.i2ptunnel.socks; import java.net.Socket; import net.i2p.client.streaming.I2PSocket; -import net.i2p.i2ptunnel.I2PTunnel; import net.i2p.util.Log; /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java index 0adaa1950..0490a6f0a 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java @@ -7,10 +7,7 @@ import java.util.Map; import net.i2p.data.Destination; import net.i2p.i2ptunnel.I2PTunnel; -import net.i2p.i2ptunnel.Logging; -import net.i2p.i2ptunnel.udp.*; import net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPClientBase; -import net.i2p.util.EventDispatcher; /** * A Datagram Tunnel that can have multiple bidirectional ports on the UDP side. @@ -63,12 +60,14 @@ public class SOCKSUDPTunnel extends I2PTunnelUDPClientBase { } } + @Override public final void startRunning() { super.startRunning(); // demuxer start() doesn't do anything startall(); } + @Override public boolean close(boolean forced) { stopall(); return super.close(forced); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java index a3a797536..29d1186c4 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java @@ -54,6 +54,6 @@ public class Pinger implements Source, Runnable { protected Sink sink; protected Thread thread; - protected Object waitlock; + protected Object waitlock; // should be final and use a factory. LINT protected boolean running; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrConsumer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrConsumer.java index 87ea0eefe..9c1d584ae 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrConsumer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrConsumer.java @@ -7,7 +7,6 @@ package net.i2p.i2ptunnel.streamr; import java.net.InetAddress; -import net.i2p.data.Destination; import net.i2p.i2ptunnel.I2PTunnel; import net.i2p.i2ptunnel.Logging; import net.i2p.i2ptunnel.udp.*; @@ -38,6 +37,7 @@ public class StreamrConsumer extends I2PTunnelUDPClientBase { this.pinger.setSink(this); } + @Override public final void startRunning() { super.startRunning(); // send subscribe-message @@ -45,6 +45,7 @@ public class StreamrConsumer extends I2PTunnelUDPClientBase { l.log("Streamr client ready"); } + @Override public boolean close(boolean forced) { // send unsubscribe-message this.pinger.stop(); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrProducer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrProducer.java index b801cb94f..7d6b14491 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrProducer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/StreamrProducer.java @@ -9,7 +9,6 @@ package net.i2p.i2ptunnel.streamr; import java.io.File; // i2p -import net.i2p.client.I2PSession; import net.i2p.i2ptunnel.I2PTunnel; import net.i2p.i2ptunnel.Logging; import net.i2p.i2ptunnel.udp.*; @@ -45,12 +44,14 @@ public class StreamrProducer extends I2PTunnelUDPServerBase { this.server.setSink(this.multi); } + @Override public final void startRunning() { super.startRunning(); this.server.start(); l.log("Streamr server ready"); } + @Override public boolean close(boolean forced) { this.server.stop(); this.multi.stop(); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java index 97abdb889..377292dde 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java @@ -6,17 +6,12 @@ package net.i2p.i2ptunnel.streamr; // system -import java.io.File; import java.util.Set; // i2p import net.i2p.client.I2PSession; import net.i2p.data.Destination; -import net.i2p.i2ptunnel.I2PTunnel; -import net.i2p.i2ptunnel.Logging; import net.i2p.i2ptunnel.udp.*; -import net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPServerBase; -import net.i2p.util.EventDispatcher; import net.i2p.util.ConcurrentHashSet; /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java index f7a1bf541..e08596af1 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java @@ -69,5 +69,5 @@ public class I2PSink implements Sink { protected boolean raw; protected I2PSession sess; protected Destination dest; - protected I2PDatagramMaker maker; + protected I2PDatagramMaker maker; // should be final and use a factory. LINT } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java index 54d5a7d97..2da942a74 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java @@ -67,5 +67,5 @@ public class I2PSinkAnywhere implements Sink { protected boolean raw; protected I2PSession sess; protected Destination dest; - protected I2PDatagramMaker maker; + protected I2PDatagramMaker maker; // should be final and use a factory. LINT } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java index b592af5e4..14945c842 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java @@ -5,21 +5,9 @@ package net.i2p.i2ptunnel.udpTunnel; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.net.ConnectException; -import java.net.InetAddress; -import java.net.NoRouteToHostException; import java.net.ServerSocket; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; import net.i2p.I2PAppContext; -import net.i2p.I2PException; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; import net.i2p.client.I2PSession; @@ -31,7 +19,6 @@ import net.i2p.i2ptunnel.I2PTunnelTask; import net.i2p.i2ptunnel.Logging; import net.i2p.i2ptunnel.udp.*; import net.i2p.util.EventDispatcher; -import net.i2p.util.I2PThread; import net.i2p.util.Log; /** @@ -107,11 +94,11 @@ import net.i2p.util.Log; // create i2pclient and destination I2PClient client = I2PClientFactory.createClient(); - Destination dest; + Destination destN; byte[] key; try { ByteArrayOutputStream out = new ByteArrayOutputStream(512); - dest = client.createDestination(out); + destN = client.createDestination(out); key = out.toByteArray(); } catch(Exception exc) { throw new RuntimeException("failed to create i2p-destination", exc); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java index 2ab2687ff..6ba8379f9 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java @@ -3,33 +3,22 @@ */ package net.i2p.i2ptunnel.udpTunnel; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.net.ConnectException; -import java.net.InetAddress; -import java.net.Socket; -import java.net.SocketException; -import java.net.SocketTimeoutException; -import java.util.Iterator; -import java.util.Properties; -import net.i2p.I2PAppContext; import net.i2p.I2PException; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; import net.i2p.client.I2PSession; import net.i2p.client.I2PSessionException; -import net.i2p.data.Base64; import net.i2p.data.Destination; import net.i2p.i2ptunnel.I2PTunnel; import net.i2p.i2ptunnel.I2PTunnelTask; import net.i2p.i2ptunnel.Logging; import net.i2p.i2ptunnel.udp.*; import net.i2p.util.EventDispatcher; -import net.i2p.util.I2PThread; import net.i2p.util.Log; /** @@ -59,7 +48,7 @@ public class I2PTunnelUDPServerBase extends I2PTunnelTask implements Source, Sin private final static Log _log = new Log(I2PTunnelUDPServerBase.class); - private Object lock = new Object(); + private final Object lock = new Object(); protected Object slock = new Object(); private static volatile long __serverId = 0; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 0a909c62e..a029de725 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -8,7 +8,6 @@ package net.i2p.i2ptunnel.web; * */ -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Properties; diff --git a/history.txt b/history.txt index 807629d8c..5d2643a9d 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,8 @@ +2009-04-11 sponge + * i2ptunnel janitorial work and fixes on most locks. + Some locks still need work, and are marked with LINT in the comment. + Just grep for "LINT" to see where the remaining places are. + 2009-04-10 sponge * More BOB threadgroup fixes, plus debug dump when things go wrong. * Fixes to streaminglib, I2CP, which are related to the TG problem. diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 6501cf5a7..9900aa288 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -17,7 +17,7 @@ import net.i2p.CoreVersion; public class RouterVersion { public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 15; + public final static long BUILD = 16; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);