minor cleanups

This commit is contained in:
zzz
2012-09-06 19:25:31 +00:00
parent b8949eafe2
commit 0c5b4c05c6
2 changed files with 19 additions and 13 deletions

View File

@ -809,7 +809,7 @@ public class TunnelDispatcher implements Service {
}
******/
public void startup() {
public synchronized void startup() {
// Note that we only use the validator for participants and OBEPs, not IBGWs, so
// this BW estimate will be high by about 33% assuming 2-hop tunnels average
_validator = new BloomFilterIVValidator(_context, getShareBandwidth(_context));
@ -823,7 +823,7 @@ public class TunnelDispatcher implements Service {
return (int) (pct * Math.min(irateKBps, orateKBps));
}
public void shutdown() {
public synchronized void shutdown() {
if (_validator != null)
_validator.destroy();
_validator = null;
@ -833,6 +833,7 @@ public class TunnelDispatcher implements Service {
_participants.clear();
_inboundGateways.clear();
_participatingConfig.clear();
_leaveJob.clear();
}
public void restart() {
@ -866,6 +867,10 @@ public class TunnelDispatcher implements Service {
public void add(HopConfig cfg) {
_configs.offer(cfg);
}
public void clear() {
_configs.clear();
}
public String getName() { return "Expire participating tunnels"; }
public void runJob() {

View File

@ -54,7 +54,7 @@ class TunnelGateway {
* @param receiver this receives the encrypted message and forwards it off
* to the first hop
*/
public TunnelGateway(RouterContext context, QueuePreprocessor preprocessor, Sender sender, Receiver receiver) {
protected TunnelGateway(RouterContext context, QueuePreprocessor preprocessor, Sender sender, Receiver receiver) {
_context = context;
_log = context.logManager().getLog(getClass());
_queue = new ArrayList(4);
@ -192,26 +192,27 @@ class TunnelGateway {
public void timeReached() {
boolean wantRequeue = false;
int remaining = 0;
long beforeLock = _context.clock().now();
long afterChecked = -1;
//int remaining = 0;
//long beforeLock = _context.clock().now();
//long afterChecked = -1;
long delayAmount = -1;
//if (_queue.size() > 10000) // stay out of the synchronized block
// System.out.println("foo!");
synchronized (_queue) {
//if (_queue.size() > 10000) // stay in the synchronized block
// System.out.println("foo!");
afterChecked = _context.clock().now();
//afterChecked = _context.clock().now();
if (!_queue.isEmpty()) {
if ( (remaining > 0) && (_log.shouldLog(Log.DEBUG)) )
_log.debug("Remaining before delayed flush preprocessing: " + _queue);
//if ( (remaining > 0) && (_log.shouldLog(Log.DEBUG)) )
// _log.debug("Remaining before delayed flush preprocessing: " + _queue);
wantRequeue = _preprocessor.preprocessQueue(_queue, _sender, _receiver);
if (wantRequeue)
if (wantRequeue) {
delayAmount = _preprocessor.getDelayAmount();
if (_log.shouldLog(Log.DEBUG))
_log.debug("Remaining after delayed flush preprocessing (requeue? " + wantRequeue + "): " + _queue);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Remaining after delayed flush preprocessing: " + _queue);
}
}
remaining = _queue.size();
//remaining = _queue.size();
}
if (wantRequeue)