forked from I2P_Developers/i2p.i2p
I2CP: Don't throw exception on early internalConnect()
ClientManager.isAlive() returns true even on port conflict Hide port conflict message in console
This commit is contained in:
@ -220,11 +220,13 @@ public class SummaryHelper extends HelperBase {
|
|||||||
private NetworkStateMessage reachability() {
|
private NetworkStateMessage reachability() {
|
||||||
if (_context.commSystem().isDummy())
|
if (_context.commSystem().isDummy())
|
||||||
return new NetworkStateMessage(NetworkState.VMCOMM, "VM Comm System");
|
return new NetworkStateMessage(NetworkState.VMCOMM, "VM Comm System");
|
||||||
|
/*
|
||||||
if (_context.router().getUptime() > 60*1000 &&
|
if (_context.router().getUptime() > 60*1000 &&
|
||||||
!_context.clientManager().isAlive() &&
|
!_context.clientManager().isAlive() &&
|
||||||
!_context.router().gracefulShutdownInProgress() &&
|
!_context.router().gracefulShutdownInProgress() &&
|
||||||
!_context.router().isRestarting())
|
!_context.router().isRestarting())
|
||||||
return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Client Manager I2CP Error - check logs")); // not a router problem but the user should know
|
return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Client Manager I2CP Error - check logs")); // not a router problem but the user should know
|
||||||
|
*/
|
||||||
// Warn based on actual skew from peers, not update status, so if we successfully offset
|
// Warn based on actual skew from peers, not update status, so if we successfully offset
|
||||||
// the clock, we don't complain.
|
// the clock, we don't complain.
|
||||||
//if (!_context.clock().getUpdatedSuccessfully())
|
//if (!_context.clock().getUpdatedSuccessfully())
|
||||||
|
@ -72,7 +72,7 @@ class ClientManager {
|
|||||||
private final Set<Hash> _metaHashes;
|
private final Set<Hash> _metaHashes;
|
||||||
protected final RouterContext _ctx;
|
protected final RouterContext _ctx;
|
||||||
protected final int _port;
|
protected final int _port;
|
||||||
protected volatile boolean _isStarted;
|
protected volatile boolean _isStarted, _wasStarted;
|
||||||
private final SimpleTimer2.TimedEvent _clientTimestamper;
|
private final SimpleTimer2.TimedEvent _clientTimestamper;
|
||||||
|
|
||||||
/** Disable external interface, allow internal clients only @since 0.8.3 */
|
/** Disable external interface, allow internal clients only @since 0.8.3 */
|
||||||
@ -169,6 +169,9 @@ class ClientManager {
|
|||||||
_clientTimestamper.schedule(ClientTimestamper.LOOP_TIME);
|
_clientTimestamper.schedule(ClientTimestamper.LOOP_TIME);
|
||||||
}
|
}
|
||||||
_isStarted = true;
|
_isStarted = true;
|
||||||
|
_wasStarted = true;
|
||||||
|
if (_log.shouldInfo())
|
||||||
|
_log.info("Started the ClientManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void restart() {
|
public synchronized void restart() {
|
||||||
@ -214,8 +217,23 @@ class ClientManager {
|
|||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
*/
|
*/
|
||||||
public I2CPMessageQueue internalConnect() throws I2PSessionException {
|
public I2CPMessageQueue internalConnect() throws I2PSessionException {
|
||||||
if (!_isStarted)
|
if (!_isStarted) {
|
||||||
|
if (_wasStarted)
|
||||||
throw new I2PSessionException("Router client manager is shut down");
|
throw new I2PSessionException("Router client manager is shut down");
|
||||||
|
// don't throw the early birds out
|
||||||
|
// ClientManager starts shortly after the console, should be less than a second
|
||||||
|
// Wait up to 60 secs before giving up
|
||||||
|
int i = 0;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
throw new I2PSessionException("Router client manager interrupted", ie);
|
||||||
|
}
|
||||||
|
} while (!_isStarted && i++ < 300);
|
||||||
|
if (!_isStarted)
|
||||||
|
throw new I2PSessionException("Router client manager failed to start");
|
||||||
|
}
|
||||||
LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
|
LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
|
||||||
LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
|
LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
|
||||||
I2CPMessageQueue myQueue = new I2CPMessageQueueImpl(in, out);
|
I2CPMessageQueue myQueue = new I2CPMessageQueueImpl(in, out);
|
||||||
@ -225,13 +243,15 @@ class ClientManager {
|
|||||||
return hisQueue;
|
return hisQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As of 0.9.45, this returns true iff the ClientManager is running.
|
||||||
|
* Prior to that, it also required all external I2CP listeners
|
||||||
|
* that were registered to be running.
|
||||||
|
* Since most of our connections are in-JVM, we now return true even
|
||||||
|
* if we have I2CP port conflicts.
|
||||||
|
*/
|
||||||
public synchronized boolean isAlive() {
|
public synchronized boolean isAlive() {
|
||||||
boolean listening = true;
|
return _isStarted;
|
||||||
if (!_listeners.isEmpty()) {
|
|
||||||
for (ClientListenerRunner listener : _listeners)
|
|
||||||
listening = listening && listener.isListening();
|
|
||||||
}
|
|
||||||
return _isStarted && (_listeners.isEmpty() || listening);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerConnection(ClientConnectionRunner runner) {
|
public void registerConnection(ClientConnectionRunner runner) {
|
||||||
|
Reference in New Issue
Block a user