forked from I2P_Developers/i2p.i2p
merge of '398a24f487b61ef778a2e849660e953ef7e43b39'
and '598d00efae4c9b675b64fd626bc2eab2b921e0c5'
This commit is contained in:
@@ -39,11 +39,21 @@ public abstract class JobImpl implements Job {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* As of 0.8.1, this is a noop, as it just adds classes to the log manager
|
||||
* class list for no good reason. Logging in jobs is almost always
|
||||
* set explicitly rather than by class name.
|
||||
*/
|
||||
void addedToQueue() {
|
||||
if (_context.logManager().getLog(getClass()).shouldLog(Log.DEBUG))
|
||||
_addedBy = new Exception();
|
||||
//if (_context.logManager().getLog(getClass()).shouldLog(Log.DEBUG))
|
||||
// _addedBy = new Exception();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return null always
|
||||
*/
|
||||
public Exception getAddedBy() { return _addedBy; }
|
||||
public long getMadeReadyOn() { return _madeReadyOn; }
|
||||
public void madeReady() { _madeReadyOn = _context.clock().now(); }
|
||||
|
||||
@@ -142,8 +142,9 @@ public class JobQueue {
|
||||
public void addJob(Job job) {
|
||||
if (job == null || !_alive) return;
|
||||
|
||||
if (job instanceof JobImpl)
|
||||
((JobImpl)job).addedToQueue();
|
||||
// This does nothing
|
||||
//if (job instanceof JobImpl)
|
||||
// ((JobImpl)job).addedToQueue();
|
||||
|
||||
long numReady = 0;
|
||||
boolean alreadyExists = false;
|
||||
|
||||
@@ -218,6 +218,19 @@ public class Router {
|
||||
// NOW we start all the activity
|
||||
_context.initAll();
|
||||
|
||||
// Set wrapper.log permissions.
|
||||
// Just hope this is the right location, we don't know for sure,
|
||||
// but this is the same method used in LogsHelper and we have no complaints.
|
||||
// (we could look for the wrapper.config file and parse it I guess...)
|
||||
// If we don't have a wrapper, RouterLaunch does this for us.
|
||||
if (System.getProperty("wrapper.version") != null) {
|
||||
File f = new File(System.getProperty("java.io.tmpdir"), "wrapper.log");
|
||||
if (!f.exists())
|
||||
f = new File(_context.getBaseDir(), "wrapper.log");
|
||||
if (f.exists())
|
||||
SecureFileOutputStream.setPerms(f);
|
||||
}
|
||||
|
||||
_routerInfo = null;
|
||||
_higherVersionSeen = false;
|
||||
_log = _context.logManager().getLog(Router.class);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 05;
|
||||
public final static long BUILD = 9;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
||||
@@ -361,18 +361,21 @@ public class ClientConnectionRunner {
|
||||
// TunnelPool.locked_buildNewLeaseSet() ensures that leases are sorted,
|
||||
// so the comparison will always work.
|
||||
int leases = set.getLeaseCount();
|
||||
if (_currentLeaseSet != null && _currentLeaseSet.getLeaseCount() == leases) {
|
||||
for (int i = 0; i < leases; i++) {
|
||||
if (! _currentLeaseSet.getLease(i).getTunnelId().equals(set.getLease(i).getTunnelId()))
|
||||
break;
|
||||
if (! _currentLeaseSet.getLease(i).getGateway().equals(set.getLease(i).getGateway()))
|
||||
break;
|
||||
if (i == leases - 1) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Requested leaseSet hasn't changed");
|
||||
if (onCreateJob != null)
|
||||
_context.jobQueue().addJob(onCreateJob);
|
||||
return; // no change
|
||||
// synch so _currentLeaseSet isn't changed out from under us
|
||||
synchronized (this) {
|
||||
if (_currentLeaseSet != null && _currentLeaseSet.getLeaseCount() == leases) {
|
||||
for (int i = 0; i < leases; i++) {
|
||||
if (! _currentLeaseSet.getLease(i).getTunnelId().equals(set.getLease(i).getTunnelId()))
|
||||
break;
|
||||
if (! _currentLeaseSet.getLease(i).getGateway().equals(set.getLease(i).getGateway()))
|
||||
break;
|
||||
if (i == leases - 1) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Requested leaseSet hasn't changed");
|
||||
if (onCreateJob != null)
|
||||
_context.jobQueue().addJob(onCreateJob);
|
||||
return; // no change
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -590,7 +593,7 @@ public class ClientConnectionRunner {
|
||||
+ " for session [" + _sessionId.getSessionId()
|
||||
+ "] (with nonce=2), retrying after ["
|
||||
+ (_context.clock().now() - _lastTried)
|
||||
+ "]", getAddedBy());
|
||||
+ "]");
|
||||
} else {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Updating message status for message " + _messageId + " to "
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SendMessageDirectJob extends JobImpl {
|
||||
if (_expiration < now) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Timed out sending message " + _message + " directly (expiration = "
|
||||
+ new Date(_expiration) + ") to " + _targetHash.toBase64(), getAddedBy());
|
||||
+ new Date(_expiration) + ") to " + _targetHash.toBase64());
|
||||
if (_onFail != null)
|
||||
getContext().jobQueue().addJob(_onFail);
|
||||
return;
|
||||
@@ -104,7 +104,7 @@ public class SendMessageDirectJob extends JobImpl {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Unable to find the router to send to: " + _targetHash
|
||||
+ " after searching for " + (getContext().clock().now()-_searchOn)
|
||||
+ "ms, message: " + _message, getAddedBy());
|
||||
+ "ms, message: " + _message);
|
||||
if (_onFail != null)
|
||||
getContext().jobQueue().addJob(_onFail);
|
||||
}
|
||||
|
||||
@@ -136,17 +136,17 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
|
||||
@Override
|
||||
public boolean isBacklogged(Hash dest) {
|
||||
return _manager.isBacklogged(dest);
|
||||
return _manager != null && _manager.isBacklogged(dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEstablished(Hash dest) {
|
||||
return _manager.isEstablished(dest);
|
||||
return _manager != null && _manager.isEstablished(dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasUnreachable(Hash dest) {
|
||||
return _manager.wasUnreachable(dest);
|
||||
return _manager != null && _manager.wasUnreachable(dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -615,8 +615,8 @@ public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Type " + msg.getMessage().getType() + " pri " + msg.getPriority() + " slot " + slot);
|
||||
boolean removed = _outbound.remove(msg);
|
||||
if ((!removed) && _log.shouldLog(Log.ERROR))
|
||||
_log.info("Already removed??? " + msg.getMessage().getType());
|
||||
if ((!removed) && _log.shouldLog(Log.WARN))
|
||||
_log.warn("Already removed??? " + msg.getMessage().getType());
|
||||
}
|
||||
_currentOutbound = msg;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.i2p.router.transport.ntcp;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@@ -24,9 +25,9 @@ import net.i2p.util.Log;
|
||||
*/
|
||||
public class NTCPSendFinisher {
|
||||
private static final int THREADS = 4;
|
||||
private I2PAppContext _context;
|
||||
private NTCPTransport _transport;
|
||||
private Log _log;
|
||||
private final I2PAppContext _context;
|
||||
private final NTCPTransport _transport;
|
||||
private final Log _log;
|
||||
private int _count;
|
||||
private ThreadPoolExecutor _executor;
|
||||
|
||||
@@ -47,7 +48,12 @@ public class NTCPSendFinisher {
|
||||
}
|
||||
|
||||
public void add(OutNetMessage msg) {
|
||||
_executor.execute(new RunnableEvent(msg));
|
||||
try {
|
||||
_executor.execute(new RunnableEvent(msg));
|
||||
} catch (RejectedExecutionException ree) {
|
||||
// race with stop()
|
||||
_log.warn("NTCP send finisher stopped, discarding msg.afterSend()");
|
||||
}
|
||||
}
|
||||
|
||||
// not really needed for now but in case we want to add some hooks like afterExecute()
|
||||
|
||||
@@ -317,7 +317,7 @@ class TestJob extends JobImpl {
|
||||
public String getName() { return "Tunnel test timeout"; }
|
||||
public void runJob() {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Timeout: found? " + _found, getAddedBy());
|
||||
_log.warn("Timeout: found? " + _found);
|
||||
if (!_found) {
|
||||
// don't clog up the SKM with old one-tag tagsets
|
||||
if (_cfg.isInbound() && !_pool.getSettings().isExploratory()) {
|
||||
|
||||
Reference in New Issue
Block a user