First step for the "connection refused" concept: incoming connections

won't be accepted until the server app actually requires an I2PServerSocket
from the I2PSocketManager.
It allows both to add a little bit of functionality, and to fix a nasty bug: it
was possible to hang an app that connects through the I2PSocketManager but
actually doesn't accept() connections (if 2 connection requests were sent
to the app, the I2PSocketManager got stuck waiting forever on
I2PServerSocketImpl.getNewSocket()).
This commit is contained in:
human
2004-04-16 03:31:13 +00:00
committed by zzz
parent 2a619f3fba
commit 031338d84d
2 changed files with 34 additions and 12 deletions

View File

@@ -63,7 +63,7 @@ class I2PSocketImpl implements I2PSocket {
public String getRemoteID(boolean wait, long maxWait) throws InterruptedIOException {
long dieAfter = System.currentTimeMillis() + maxWait;
synchronized (remoteIDWaiter) {
while (wait && remoteID == null) {
if (wait) {
try {
if (maxWait > 0)
remoteIDWaiter.wait(maxWait);
@@ -74,8 +74,7 @@ class I2PSocketImpl implements I2PSocket {
if ((maxWait > 0) && (System.currentTimeMillis() > dieAfter))
throw new InterruptedIOException("Timed out waiting for remote ID");
}
if (wait) {
_log.debug("TIMING: RemoteID set to " + I2PSocketManager.getReadableForm(remoteID) + " for "
+ this.hashCode());
}
@@ -333,4 +332,4 @@ class I2PSocketImpl implements I2PSocket {
return sent;
}
}
}
}