diff --git a/apps/routerconsole/jsp/configadvanced.jsp b/apps/routerconsole/jsp/configadvanced.jsp index 473928e9b..962a9c772 100644 --- a/apps/routerconsole/jsp/configadvanced.jsp +++ b/apps/routerconsole/jsp/configadvanced.jsp @@ -29,10 +29,12 @@ " />
-
+ + If you are changing any of the I2NP settings, you should go to the + service config page and do a graceful restart after saving. diff --git a/apps/sam/java/src/net/i2p/sam/SAMHandler.java b/apps/sam/java/src/net/i2p/sam/SAMHandler.java index 16efe9279..a7b250207 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMHandler.java +++ b/apps/sam/java/src/net/i2p/sam/SAMHandler.java @@ -100,6 +100,14 @@ public abstract class SAMHandler implements Runnable { socketOS.flush(); } } + + /** + * If you're crazy enough to write to the raw socket, grab the write lock + * with getWriteLock(), synchronize against it, and write to the getOut() + * + */ + protected Object getWriteLock() { return socketWLock; } + protected OutputStream getOut() { return socketOS; } /** * Write a string to the handler's socket. This method must diff --git a/apps/sam/java/src/net/i2p/sam/SAMv1Handler.java b/apps/sam/java/src/net/i2p/sam/SAMv1Handler.java index a085f9074..822fa5c72 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMv1Handler.java +++ b/apps/sam/java/src/net/i2p/sam/SAMv1Handler.java @@ -14,6 +14,7 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; +import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.NoRouteToHostException; @@ -765,15 +766,24 @@ public class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatag throw new NullPointerException("BUG! STREAM session is null!"); } - ByteArrayOutputStream msg = new ByteArrayOutputStream(); - String msgText = "STREAM RECEIVED ID=" + id +" SIZE=" + len + "\n"; if (_log.shouldLog(Log.DEBUG)) _log.debug("sending to client: " + msgText); - msg.write(msgText.getBytes("ISO-8859-1")); - msg.write(data, 0, len); - - writeBytes(msg.toByteArray()); + + byte prefix[] = msgText.getBytes("ISO-8859-1"); + + // dont waste so much memory + //ByteArrayOutputStream msg = new ByteArrayOutputStream(); + //msg.write(msgText.getBytes("ISO-8859-1")); + //msg.write(data, 0, len); + // writeBytes(msg.toByteArray()); + Object writeLock = getWriteLock(); + OutputStream out = getOut(); + synchronized (writeLock) { + out.write(prefix); + out.write(data, 0, len); + out.flush(); + } } public void notifyStreamDisconnection(int id, String result, String msg) throws IOException { diff --git a/history.txt b/history.txt index 75b533b82..58f092145 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.79 2004/11/21 17:31:33 jrandom Exp $ +$Id: history.txt,v 1.80 2004/11/22 12:57:16 jrandom Exp $ + +2004-11-22 jrandom + * Update to the SAM bridge to reduce some unnecessary memory allocation. + * New stat to keep track of slow jobs (ones that take more than a second + to excute). This is published in the netDb as jobQueue.jobRunSlow 2004-11-21 jrandom * Update the I2PTunnel web interface to include an option for the new diff --git a/router/java/src/net/i2p/router/JobQueueRunner.java b/router/java/src/net/i2p/router/JobQueueRunner.java index be11dea91..3257c93bf 100644 --- a/router/java/src/net/i2p/router/JobQueueRunner.java +++ b/router/java/src/net/i2p/router/JobQueueRunner.java @@ -24,6 +24,7 @@ class JobQueueRunner implements Runnable { _lastJob = null; _log = _context.logManager().getLog(JobQueueRunner.class); _context.statManager().createRateStat("jobQueue.jobRun", "How long jobs take", "JobQueue", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l }); + _context.statManager().createRateStat("jobQueue.jobRunSlow", "How long jobs that take over a second take", "JobQueue", new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000l }); _context.statManager().createRateStat("jobQueue.jobLag", "How long jobs have to wait before running", "JobQueue", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l }); _context.statManager().createRateStat("jobQueue.jobWait", "How long does a job sat on the job queue?", "JobQueue", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l }); _context.statManager().createRateStat("jobQueue.jobRunnerInactive", "How long are runners inactive?", "JobQueue", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l }); @@ -96,13 +97,15 @@ class JobQueueRunner implements Runnable { _context.statManager().addRateData("jobQueue.jobLag", doStart - origStartAfter, 0); _context.statManager().addRateData("jobQueue.jobWait", enqueuedTime, enqueuedTime); + if (duration > 1000) { + _context.statManager().addRateData("jobQueue.jobRunSlow", duration, duration); + if (_log.shouldLog(Log.WARN)) + _log.warn("Duration of " + duration + " (lag "+ (doStart-origStartAfter) + + ") on job " + _currentJob); + } + _state = 14; - - if ( (duration > 1000) && (_log.shouldLog(Log.WARN)) ) - _log.warn("Duration of " + duration + " (lag "+ (doStart-origStartAfter) - + ") on job " + _currentJob); - if (diff > 100) { if (_log.shouldLog(Log.WARN)) _log.warn("Updating statistics for the job took too long [" + diff + "ms]"); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 31df88dad..bc8fdec6c 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.84 $ $Date: 2004/11/21 17:31:33 $"; + public final static String ID = "$Revision: 1.85 $ $Date: 2004/11/22 12:57:16 $"; public final static String VERSION = "0.4.1.4"; - public final static long BUILD = 13; + public final static long BUILD = 14; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/StatisticsManager.java b/router/java/src/net/i2p/router/StatisticsManager.java index bf5e67b34..d7f115874 100644 --- a/router/java/src/net/i2p/router/StatisticsManager.java +++ b/router/java/src/net/i2p/router/StatisticsManager.java @@ -106,6 +106,7 @@ public class StatisticsManager implements Service { //includeRate("tcp.queueSize", stats); //includeRate("jobQueue.jobLag", stats, new long[] { 60*1000, 60*60*1000 }); //includeRate("jobQueue.jobRun", stats, new long[] { 60*1000, 60*60*1000 }); + includeRate("jobQueue.jobRunSlow", stats, new long[] { 10*60*1000l, 60*60*1000l }); includeRate("crypto.elGamal.encrypt", stats, new long[] { 60*60*1000 }); //includeRate("crypto.garlic.decryptFail", stats, new long[] { 60*60*1000, 24*60*60*1000 }); includeRate("tunnel.unknownTunnelTimeLeft", stats, new long[] { 60*60*1000 });