forked from I2P_Developers/i2p.i2p
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user