merge of 'a0b025f180c1f7befcc1eb504c24140cf9e3fc0f'

and 'e0773d79a9bc8820024206f39686541ddb393c4a'
This commit is contained in:
dg2-new
2015-06-29 20:22:10 +00:00
19 changed files with 155 additions and 71 deletions

View File

@@ -252,8 +252,8 @@ Applications:
Bundles systray4j-2.4.1: Bundles systray4j-2.4.1:
See licenses/LICENSE-LGPLv2.1.txt See licenses/LICENSE-LGPLv2.1.txt
Tomcat 6.0.43: Tomcat 6.0.44:
Copyright 1999-2014 The Apache Software Foundation Copyright 1999-2015 The Apache Software Foundation
See licenses/LICENSE-Apache2.0.txt See licenses/LICENSE-Apache2.0.txt
See licenses/NOTICE-Tomcat.txt See licenses/NOTICE-Tomcat.txt

View File

@@ -1,5 +1,5 @@
Apache Tomcat Apache Tomcat
Copyright 1999-2014 The Apache Software Foundation Copyright 1999-2015 The Apache Software Foundation
This product includes software developed at This product includes software developed at
The Apache Software Foundation (http://www.apache.org/). The Apache Software Foundation (http://www.apache.org/).

View File

@@ -2,7 +2,7 @@ This is Apache Tomcat 6.x, supporting Servlet 2.5 and JSP 2.1.
The Glassfish JSP 2.1 bundled in Jetty 6 is way too old. The Glassfish JSP 2.1 bundled in Jetty 6 is way too old.
Retrieved from the file Retrieved from the file
apache-tomcat-6.0.43-deployer.tar.gz apache-tomcat-6.0.44-deployer.tar.gz
minus the following files and directores: minus the following files and directores:

View File

@@ -1,7 +1,7 @@
This is Apache Tomcat 6.x, supporting Servlet 2.5 and JSP 2.1. This is Apache Tomcat 6.x, supporting Servlet 2.5 and JSP 2.1.
Retrieved from the file Retrieved from the file
apache-tomcat-6.0.43.tar.gz apache-tomcat-6.0.44.tar.gz
containing only a small subset of lib/tomcat-coyote.jar. containing only a small subset of lib/tomcat-coyote.jar.

View File

@@ -10,7 +10,7 @@
<property name="javac.compilerargs" value="" /> <property name="javac.compilerargs" value="" />
<property name="javac.version" value="1.6" /> <property name="javac.version" value="1.6" />
<property name="tomcat.lib" value="apache-tomcat-deployer/lib" /> <property name="tomcat.lib" value="apache-tomcat-deployer/lib" />
<property name="tomcat.ver" value="6.0.43" /> <property name="tomcat.ver" value="6.0.44" />
<property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" /> <property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" />
<property name="tomcat2.lib.small" value="apache-tomcat/lib" /> <property name="tomcat2.lib.small" value="apache-tomcat/lib" />

View File

@@ -16,6 +16,7 @@ package net.i2p.jetty;
// limitations under the License. // limitations under the License.
// ======================================================================== // ========================================================================
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -25,8 +26,10 @@ import java.util.Properties;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.app.*; import net.i2p.app.*;
import static net.i2p.app.ClientAppState.*; import static net.i2p.app.ClientAppState.*;
import net.i2p.util.PortMapper;
import java.io.InputStream; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
@@ -45,13 +48,15 @@ public class JettyStart implements ClientApp {
private final ClientAppManager _mgr; private final ClientAppManager _mgr;
private final String[] _args; private final String[] _args;
private final List<LifeCycle> _jettys; private final List<LifeCycle> _jettys;
private final I2PAppContext _context;
private volatile ClientAppState _state; private volatile ClientAppState _state;
private volatile int _port;
/** /**
* All args must be XML file names. * All args must be XML file names.
* Does not support any of the other argument types from org.mortbay.start.Main. * Does not support any of the other argument types from org.mortbay.start.Main.
* *
* @param context unused, may be null * @param context may be null
* @param mgr may be null e.g. for use in plugins * @param mgr may be null e.g. for use in plugins
*/ */
public JettyStart(I2PAppContext context, ClientAppManager mgr, String[] args) throws Exception { public JettyStart(I2PAppContext context, ClientAppManager mgr, String[] args) throws Exception {
@@ -59,6 +64,7 @@ public class JettyStart implements ClientApp {
_mgr = mgr; _mgr = mgr;
_args = args; _args = args;
_jettys = new ArrayList<LifeCycle>(args.length); _jettys = new ArrayList<LifeCycle>(args.length);
_context = context;
parseArgs(args); parseArgs(args);
_state = INITIALIZED; _state = INITIALIZED;
} }
@@ -116,6 +122,22 @@ public class JettyStart implements ClientApp {
if (!lc.isRunning()) { if (!lc.isRunning()) {
try { try {
lc.start(); lc.start();
if (_context != null && _context.portMapper().getPort(PortMapper.SVC_EEPSITE) <= 0) {
if (lc instanceof Server) {
Server server = (Server) lc;
Connector[] connectors = server.getConnectors();
if (connectors.length > 0) {
int port = connectors[0].getPort();
if (port > 0) {
_port = port;
String host = connectors[0].getHost();
if (host.equals("0.0.0.0") || host.equals("::"))
host = "127.0.0.1";
_context.portMapper().register(PortMapper.SVC_EEPSITE, host, port);
}
}
}
}
} catch (Exception e) { } catch (Exception e) {
changeState(START_FAILED, e); changeState(START_FAILED, e);
return; return;
@@ -154,6 +176,10 @@ public class JettyStart implements ClientApp {
} }
} }
} }
if (_context != null && _port > 0 && _context.portMapper().getPort(PortMapper.SVC_EEPSITE) == _port) {
_port = 0;
_context.portMapper().unregister(PortMapper.SVC_EEPSITE);
}
changeState(STOPPED); changeState(STOPPED);
} }
} }

View File

@@ -167,13 +167,22 @@ public class HomeHelper extends HelperBase {
ctx.router().saveConfig(prop, buf.toString()); ctx.router().saveConfig(prop, buf.toString());
} }
private static String renderApps(Collection<App> apps) { private String renderApps(Collection<App> apps) {
String website = _("Website");
StringBuilder buf = new StringBuilder(1024); StringBuilder buf = new StringBuilder(1024);
buf.append("<div class=\"appgroup\">"); buf.append("<div class=\"appgroup\">");
for (App app : apps) { for (App app : apps) {
String url;
if (app.name.equals(website) && app.url.equals("http://127.0.0.1:7658/")) {
// fixup eepsite link
url = "http://" + _context.portMapper().getHost(PortMapper.SVC_EEPSITE, "127.0.0.1") +
':' + _context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658) + '/';
} else {
url = app.url;
}
buf.append("<div class=\"app\">" + buf.append("<div class=\"app\">" +
"<div class=\"appimg\">" + "<div class=\"appimg\">" +
"<a href=\"").append(app.url).append("\">" + "<a href=\"").append(url).append("\">" +
"<img class=\""); "<img class=\"");
// toopie is 54x68, not 16x16, needs special alignment and sizing // toopie is 54x68, not 16x16, needs special alignment and sizing
if (app.icon.endsWith("/itoopie_sm.png")) if (app.icon.endsWith("/itoopie_sm.png"))
@@ -184,7 +193,7 @@ public class HomeHelper extends HelperBase {
"</div>" + "</div>" +
"<table class=\"app\"><tr class=\"app\"><td class=\"app\">" + "<table class=\"app\"><tr class=\"app\"><td class=\"app\">" +
"<div class=\"applabel\">" + "<div class=\"applabel\">" +
"<a href=\"").append(app.url).append("\" title=\"").append(app.desc).append("\">").append(app.name).append("</a>" + "<a href=\"").append(url).append("\" title=\"").append(app.desc).append("\">").append(app.name).append("</a>" +
"</div>" + "</div>" +
"</td></tr></table>" + "</td></tr></table>" +
"</div>\n"); "</div>\n");

View File

@@ -11,6 +11,7 @@ import java.util.Map;
import net.i2p.crypto.SigType; import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.util.PortMapper;
/** /**
* Refactored from summarynoframe.jsp to save ~100KB * Refactored from summarynoframe.jsp to save ~100KB
@@ -146,7 +147,11 @@ public class SummaryBarRenderer {
.append(nbsp(_("Torrents"))) .append(nbsp(_("Torrents")))
.append("</a>\n" + .append("</a>\n" +
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"") "<a href=\"http://")
.append(_context.portMapper().getHost(PortMapper.SVC_EEPSITE, "127.0.0.1"))
.append(':')
.append(_context.portMapper().getPort(PortMapper.SVC_EEPSITE, 7658))
.append("/\" target=\"_blank\" title=\"")
.append(_("Local web server")) .append(_("Local web server"))
.append("\">") .append("\">")
.append(nbsp(_("Website"))) .append(nbsp(_("Website")))

View File

@@ -1254,6 +1254,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
protected String getPrefix() { protected String getPrefix() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append('['); buf.append('[');
buf.append(_state.toString()).append(' ');
String s = _options.getProperty("inbound.nickname"); String s = _options.getProperty("inbound.nickname");
if (s != null) if (s != null)
buf.append(s); buf.append(s);
@@ -1262,7 +1263,6 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
SessionId id = _sessionId; SessionId id = _sessionId;
if (id != null) if (id != null)
buf.append(" #").append(id.getSessionId()); buf.append(" #").append(id.getSessionId());
buf.append(' ').append(_state.toString());
buf.append("]: "); buf.append("]: ");
return buf.toString(); return buf.toString();
} }

View File

@@ -2,6 +2,7 @@ package net.i2p.util;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -16,7 +17,7 @@ import net.i2p.I2PAppContext;
* @since 0.8.12 * @since 0.8.12
*/ */
public class PortMapper { public class PortMapper {
private final ConcurrentHashMap<String, Integer> _dir; private final ConcurrentHashMap<String, InetSocketAddress> _dir;
public static final String SVC_CONSOLE = "console"; public static final String SVC_CONSOLE = "console";
public static final String SVC_HTTPS_CONSOLE = "https_console"; public static final String SVC_HTTPS_CONSOLE = "https_console";
@@ -37,7 +38,7 @@ public class PortMapper {
* @param context unused for now * @param context unused for now
*/ */
public PortMapper(I2PAppContext context) { public PortMapper(I2PAppContext context) {
_dir = new ConcurrentHashMap<String, Integer>(8); _dir = new ConcurrentHashMap<String, InetSocketAddress>(8);
} }
/** /**
@@ -46,9 +47,19 @@ public class PortMapper {
* @return success, false if already registered * @return success, false if already registered
*/ */
public boolean register(String service, int port) { public boolean register(String service, int port) {
if (port <= 0) return register(service, "127.0.0.1", port);
}
/**
* Add the service
* @param port > 0
* @return success, false if already registered
* @since 0.9.21
*/
public boolean register(String service, String host, int port) {
if (port <= 0 || port > 65535)
return false; return false;
return _dir.putIfAbsent(service, Integer.valueOf(port)) == null; return _dir.putIfAbsent(service, InetSocketAddress.createUnresolved(host, port)) == null;
} }
/** /**
@@ -73,10 +84,24 @@ public class PortMapper {
* @return def if not registered * @return def if not registered
*/ */
public int getPort(String service, int def) { public int getPort(String service, int def) {
Integer port = _dir.get(service); InetSocketAddress ia = _dir.get(service);
if (port == null) if (ia == null)
return def; return def;
return port.intValue(); return ia.getPort();
}
/**
* Get the registered host for a service.
* Will return "127.0.0.1" if the service was registered without a host.
* @param def default
* @return def if not registered
* @since 0.9.21
*/
public String getHost(String service, String def) {
InetSocketAddress ia = _dir.get(service);
if (ia == null)
return def;
return ia.getHostName();
} }
/** /**
@@ -85,10 +110,13 @@ public class PortMapper {
*/ */
public void renderStatusHTML(Writer out) throws IOException { public void renderStatusHTML(Writer out) throws IOException {
List<String> services = new ArrayList(_dir.keySet()); List<String> services = new ArrayList(_dir.keySet());
out.write("<h2>Port Mapper</h2><table><tr><th>Service<th>Port\n"); out.write("<h2>Port Mapper</h2><table><tr><th>Service<th>Host<th>Port\n");
Collections.sort(services); Collections.sort(services);
for (String s : services) { for (String s : services) {
out.write("<tr><td>" + s + "<td>" + _dir.get(s) + '\n'); InetSocketAddress ia = _dir.get(s);
if (ia == null)
continue;
out.write("<tr><td>" + s + "<td>" + ia.getHostName() + "<td>" + ia.getPort() + '\n');
} }
out.write("</table>\n"); out.write("</table>\n");
} }

View File

@@ -1,3 +1,14 @@
2015-06-29 zzz
* Transport: More fixes for SSU stalling
2015-06-28 zzz
* Apache Tomcat 6.0.44
2015-06-25 zzz
* Console: Use registered host/port for eepsite link (ticket #1604)
* Jetty starter: Register host/port when started
* PortMapper: Add hostname support
2015-06-24 zzz 2015-06-24 zzz
* Transport: Add failsafe to prevent complete SSU stall waiting * Transport: Add failsafe to prevent complete SSU stall waiting
for bandwidth limiter for bandwidth limiter

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 11; public final static long BUILD = 13;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";

View File

@@ -433,7 +433,7 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Still denying the " + _pendingInboundRequests.size() _log.debug("Still denying the " + _pendingInboundRequests.size()
+ " pending inbound requests (status: " + getStatus().toString() + " pending inbound requests (status: " + getStatus().toString()
+ ", longest waited " + locked_getLongestInboundWait() + " in)"); + ", longest waited " + locked_getLongestInboundWait() + ')');
} }
} }
} }
@@ -505,7 +505,6 @@ public class FIFOBandwidthLimiter {
*/ */
private final void locked_satisfyInboundAvailable(List<Request> satisfied) { private final void locked_satisfyInboundAvailable(List<Request> satisfied) {
for (int i = 0; i < _pendingInboundRequests.size(); i++) { for (int i = 0; i < _pendingInboundRequests.size(); i++) {
if (_availableInbound.get() <= 0) break;
SimpleRequest req = _pendingInboundRequests.get(i); SimpleRequest req = _pendingInboundRequests.get(i);
long waited = now() - req.getRequestTime(); long waited = now() - req.getRequestTime();
if (req.getAborted()) { if (req.getAborted()) {
@@ -520,17 +519,22 @@ public class FIFOBandwidthLimiter {
i--; i--;
continue; continue;
} }
if ( (req.getAllocationsSinceWait() > 0) && (req.getCompleteListener() == null) ) { int avi = _availableInbound.get();
if (avi <= 0) break;
// NO, don't do this, since SSU requires a full allocation to proceed.
// By stopping after a partial allocation, we stall SSU.
// This never affected NTCP (which also requires a full allocation)
// since it registers a CompleteListener, so getAllocationsSinceWait() was always zero.
//if (req.getAllocationsSinceWait() > 0) {
// we have already allocated some values to this request, but // we have already allocated some values to this request, but
// they haven't taken advantage of it yet (most likely they're // they haven't taken advantage of it yet (most likely they're
// IO bound) // IO bound)
// (also, the complete listener is only set for situations where // (also, the complete listener is only set for situations where
// waitForNextAllocation() is never called) // waitForNextAllocation() is never called)
continue; // continue;
} //}
// ok, they are really waiting for us to give them stuff // ok, they are really waiting for us to give them stuff
int requested = req.getPendingRequested(); int requested = req.getPendingRequested();
int avi = _availableInbound.get();
int allocated; int allocated;
if (avi >= requested) if (avi >= requested)
allocated = requested; allocated = requested;
@@ -579,7 +583,7 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Still denying the " + _pendingOutboundRequests.size() _log.info("Still denying the " + _pendingOutboundRequests.size()
+ " pending outbound requests (status: " + getStatus().toString() + " pending outbound requests (status: " + getStatus().toString()
+ ", longest waited " + locked_getLongestOutboundWait() + " out)"); + ", longest waited " + locked_getLongestOutboundWait() + ')');
} }
} }
} }
@@ -623,7 +627,6 @@ public class FIFOBandwidthLimiter {
*/ */
private final void locked_satisfyOutboundAvailable(List<Request> satisfied) { private final void locked_satisfyOutboundAvailable(List<Request> satisfied) {
for (int i = 0; i < _pendingOutboundRequests.size(); i++) { for (int i = 0; i < _pendingOutboundRequests.size(); i++) {
if (_availableOutbound.get() <= 0) break;
SimpleRequest req = _pendingOutboundRequests.get(i); SimpleRequest req = _pendingOutboundRequests.get(i);
long waited = now() - req.getRequestTime(); long waited = now() - req.getRequestTime();
if (req.getAborted()) { if (req.getAborted()) {
@@ -638,17 +641,22 @@ public class FIFOBandwidthLimiter {
i--; i--;
continue; continue;
} }
if (req.getAllocationsSinceWait() > 0) { int avo = _availableOutbound.get();
if (avo <= 0) break;
// NO, don't do this, since SSU requires a full allocation to proceed.
// By stopping after a partial allocation, we stall SSU.
// This never affected NTCP (which also requires a full allocation)
// since it registers a CompleteListener, so getAllocationsSinceWait() was always zero.
//if (req.getAllocationsSinceWait() > 0) {
// we have already allocated some values to this request, but // we have already allocated some values to this request, but
// they haven't taken advantage of it yet (most likely they're // they haven't taken advantage of it yet (most likely they're
// IO bound) // IO bound)
if (_log.shouldLog(Log.WARN)) // if (_log.shouldLog(Log.WARN))
_log.warn("multiple allocations since wait... ntcp shouldn't do this: " + req); // _log.warn("multiple allocations since wait... ntcp shouldn't do this: " + req);
continue; // continue;
} //}
// ok, they are really waiting for us to give them stuff // ok, they are really waiting for us to give them stuff
int requested = req.getPendingRequested(); int requested = req.getPendingRequested();
int avo = _availableOutbound.get();
int allocated; int allocated;
if (avo >= requested) if (avo >= requested)
allocated = requested; allocated = requested;
@@ -659,15 +667,6 @@ public class FIFOBandwidthLimiter {
req.allocateBytes(allocated); req.allocateBytes(allocated);
satisfied.add(req); satisfied.add(req);
if (req.getPendingRequested() > 0) { if (req.getPendingRequested() > 0) {
if (req.attachment() != null) {
if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes outbound as a partial grant to "
+ req
+ " waited "
+ waited
+ "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestOutboundWait() + " out");
}
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Allocating " + allocated + " bytes outbound as a partial grant to " _log.debug("Allocating " + allocated + " bytes outbound as a partial grant to "
+ req + req
@@ -676,15 +675,6 @@ public class FIFOBandwidthLimiter {
+ "ms) pending " + _pendingOutboundRequests.size() + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestOutboundWait() + " out"); + ", longest waited " + locked_getLongestOutboundWait() + " out");
} else { } else {
if (req.attachment() != null) {
if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to "
+ req
+ " waited "
+ waited
+ "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestOutboundWait() + " out)");
}
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Allocating " + allocated + " bytes outbound to finish the partial grant to " _log.debug("Allocating " + allocated + " bytes outbound to finish the partial grant to "
+ req + req
@@ -807,9 +797,9 @@ public class FIFOBandwidthLimiter {
/** uses System clock, not context clock */ /** uses System clock, not context clock */
public long getRequestTime() { return _requestTime; } public long getRequestTime() { return _requestTime; }
public int getTotalRequested() { return _total; } public int getTotalRequested() { return _total; }
public int getPendingRequested() { return _total - _allocated; } public synchronized int getPendingRequested() { return _total - _allocated; }
public boolean getAborted() { return _aborted; } public boolean getAborted() { return _aborted; }
public void abort() { public synchronized void abort() {
_aborted = true; _aborted = true;
// so isComplete() will return true // so isComplete() will return true
_allocated = _total; _allocated = _total;
@@ -817,6 +807,9 @@ public class FIFOBandwidthLimiter {
} }
public CompleteListener getCompleteListener() { return _lsnr; } public CompleteListener getCompleteListener() { return _lsnr; }
/**
* Only used by NTCP.
*/
public void setCompleteListener(CompleteListener lsnr) { public void setCompleteListener(CompleteListener lsnr) {
boolean complete = false; boolean complete = false;
synchronized (this) { synchronized (this) {
@@ -832,18 +825,19 @@ public class FIFOBandwidthLimiter {
} }
} }
private boolean isComplete() { return _allocated >= _total; } private synchronized boolean isComplete() { return _allocated >= _total; }
/** /**
* Only used by SSU.
* May return without allocating. * May return without allocating.
* Check getPendingRequested() > 0 in a loop. * Check getPendingRequested() > 0 in a loop.
*/ */
public void waitForNextAllocation() { public void waitForNextAllocation() {
_waited = true;
_allocationsSinceWait = 0;
boolean complete = false; boolean complete = false;
try { try {
synchronized (this) { synchronized (this) {
_waited = true;
_allocationsSinceWait = 0;
if (isComplete()) if (isComplete())
complete = true; complete = true;
else else
@@ -854,17 +848,21 @@ public class FIFOBandwidthLimiter {
_lsnr.complete(this); _lsnr.complete(this);
} }
int getAllocationsSinceWait() { return _waited ? _allocationsSinceWait : 0; } /**
* Only returns nonzero if there's no listener and waitForNextAllocation()
* has been called (i.e. SSU)
* Now unused.
*/
synchronized int getAllocationsSinceWait() { return _waited ? _allocationsSinceWait : 0; }
void allocateBytes(int bytes) { /**
* Increments allocationsSinceWait only if there is a listener.
* Does not notify; caller must call notifyAllocation()
*/
synchronized void allocateBytes(int bytes) {
_allocated += bytes; _allocated += bytes;
if (_lsnr == null) if (_lsnr == null)
_allocationsSinceWait++; _allocationsSinceWait++;
//if (isComplete()) {
// if (_log.shouldLog(Log.INFO))
// _log.info("allocate " + bytes + " completed, listener=" + _lsnr);
//}
//notifyAllocation(); // handled within the satisfy* methods
} }
void notifyAllocation() { void notifyAllocation() {
@@ -893,8 +891,8 @@ public class FIFOBandwidthLimiter {
@Override @Override
public String toString() { public String toString() {
return "Req" + _requestId + " priority " + _priority + return "Req: " + _requestId + " priority: " + _priority +
_allocated + '/' + _total + " bytes"; ' ' + _allocated + '/' + _total + " bytes";
} }
} }

View File

@@ -1067,9 +1067,16 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
I2PAppContext ctx = new I2PAppContext(props); I2PAppContext ctx = new I2PAppContext(props);
UPnP upnp = new UPnP(ctx); UPnP upnp = new UPnP(ctx);
ControlPoint cp = new ControlPoint(); ControlPoint cp = new ControlPoint();
System.out.println("Searching for UPnP devices:"); long start = System.currentTimeMillis();
cp.start(); cp.start();
long s2 = System.currentTimeMillis();
System.out.println("Start took " + (s2 - start));
System.out.println("Searching for UPnP devices");
start = System.currentTimeMillis();
cp.search(); cp.search();
s2 = System.currentTimeMillis();
System.out.println("Search kickoff took " + (s2 - start));
System.out.println("Waiting 10 seconds for responses");
Thread.sleep(10000); Thread.sleep(10000);
//while(true) { //while(true) {
DeviceList list = cp.getDeviceList(); DeviceList list = cp.getDeviceList();
@@ -1081,7 +1088,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
Device device = it.next(); Device device = it.next();
upnp.listSubDev(device.toString(), device, sb); upnp.listSubDev(device.toString(), device, sb);
System.out.println("Here is the listing for device " + (++i) + System.out.println("Here is the listing for device " + (++i) +
' ' + device.getFriendlyName() + " :"); ": " + device.getFriendlyName() + " :");
System.out.println(sb.toString()); System.out.println(sb.toString());
sb.setLength(0); sb.setLength(0);
} }