I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit bb51bf49 authored by zzz's avatar zzz
Browse files

- Suppress log error on manual stop

- Prevent NPE when closing a delayed-open tunnel
parent 6c365bef
No related branches found
No related tags found
No related merge requests found
...@@ -375,7 +375,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna ...@@ -375,7 +375,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
// This will build a new socket manager and a new dest if the session is closed. // This will build a new socket manager and a new dest if the session is closed.
sockMgr = getSocketManager(); sockMgr = getSocketManager();
if (oldSockMgr != sockMgr) { if (oldSockMgr != sockMgr) {
_log.error("Built a new destination on resume"); _log.warn("Built a new destination on resume");
} }
} }
} // else the old socket manager will reconnect the old session if necessary } // else the old socket manager will reconnect the old session if necessary
...@@ -431,8 +431,10 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna ...@@ -431,8 +431,10 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
_context.statManager().addRateData("i2ptunnel.client.manageTime", total, total); _context.statManager().addRateData("i2ptunnel.client.manageTime", total, total);
} }
} catch (IOException ex) { } catch (IOException ex) {
_log.error("Error listening for connections on " + localPort, ex); if (open) {
notifyEvent("openBaseClientResult", "error"); _log.error("Error listening for connections on " + localPort, ex);
notifyEvent("openBaseClientResult", "error");
}
synchronized (sockLock) { synchronized (sockLock) {
mySockets.clear(); mySockets.clear();
} }
...@@ -513,20 +515,23 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna ...@@ -513,20 +515,23 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
// might risk to create an orphan socket. Would be better // might risk to create an orphan socket. Would be better
// to return with an error in that situation quickly. // to return with an error in that situation quickly.
synchronized (sockLock) { synchronized (sockLock) {
mySockets.retainAll(sockMgr.listSockets()); if (sockMgr != null) {
if (!forced && mySockets.size() != 0) { mySockets.retainAll(sockMgr.listSockets());
l.log("There are still active connections!"); if (!forced && mySockets.size() != 0) {
_log.debug("can't close: there are still active connections!"); l.log("There are still active connections!");
for (Iterator it = mySockets.iterator(); it.hasNext();) { _log.debug("can't close: there are still active connections!");
l.log("->" + it.next()); for (Iterator it = mySockets.iterator(); it.hasNext();) {
l.log("->" + it.next());
}
return false;
}
I2PSession session = sockMgr.getSession();
if (session != null) {
getTunnel().removeSession(session);
} }
return false;
}
I2PSession session = sockMgr.getSession();
if (session != null) {
getTunnel().removeSession(session);
} }
l.log("Closing client " + toString()); l.log("Closing client " + toString());
open = false;
try { try {
if (ss != null) ss.close(); if (ss != null) ss.close();
} catch (IOException ex) { } catch (IOException ex) {
...@@ -534,7 +539,6 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna ...@@ -534,7 +539,6 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
return false; return false;
} }
l.log("Client closed."); l.log("Client closed.");
open = false;
} }
synchronized (_waitingSockets) { _waitingSockets.notifyAll(); } synchronized (_waitingSockets) { _waitingSockets.notifyAll(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment