mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 23:59:54 +01:00
Use an unlimited read timeout for TCP sockets.
This commit is contained in:
@@ -146,6 +146,7 @@ class LanTcpPlugin extends TcpPlugin {
|
|||||||
try {
|
try {
|
||||||
// Connect back on the advertised TCP port
|
// Connect back on the advertised TCP port
|
||||||
Socket s = new Socket(packet.getAddress(), port);
|
Socket s = new Socket(packet.getAddress(), port);
|
||||||
|
s.setSoTimeout(0);
|
||||||
return new TcpTransportConnection(s);
|
return new TcpTransportConnection(s);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
if(LOG.isLoggable(WARNING))
|
if(LOG.isLoggable(WARNING))
|
||||||
@@ -286,7 +287,9 @@ class LanTcpPlugin extends TcpPlugin {
|
|||||||
try {
|
try {
|
||||||
int wait = (int) (Math.min(end, nextPacket) - now);
|
int wait = (int) (Math.min(end, nextPacket) - now);
|
||||||
ss.setSoTimeout(wait < 1 ? 1 : wait);
|
ss.setSoTimeout(wait < 1 ? 1 : wait);
|
||||||
return new TcpTransportConnection(ss.accept());
|
Socket s = ss.accept();
|
||||||
|
s.setSoTimeout(0);
|
||||||
|
return new TcpTransportConnection(s);
|
||||||
} catch(SocketTimeoutException e) {
|
} catch(SocketTimeoutException e) {
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
if(now < end) {
|
if(now < end) {
|
||||||
@@ -310,12 +313,4 @@ class LanTcpPlugin extends TcpPlugin {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryToClose(ServerSocket ss) {
|
|
||||||
try {
|
|
||||||
ss.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ abstract class TcpPlugin implements DuplexPlugin {
|
|||||||
acceptContactConnections(ss);
|
acceptContactConnections(ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryToClose(ServerSocket ss) {
|
protected void tryToClose(ServerSocket ss) {
|
||||||
try {
|
try {
|
||||||
ss.close();
|
ss.close();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
@@ -120,6 +120,7 @@ abstract class TcpPlugin implements DuplexPlugin {
|
|||||||
Socket s;
|
Socket s;
|
||||||
try {
|
try {
|
||||||
s = ss.accept();
|
s = ss.accept();
|
||||||
|
s.setSoTimeout(0);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// This is expected when the socket is closed
|
// This is expected when the socket is closed
|
||||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||||
@@ -179,6 +180,7 @@ abstract class TcpPlugin implements DuplexPlugin {
|
|||||||
Socket s = new Socket();
|
Socket s = new Socket();
|
||||||
if(addr == null || s == null) return null;
|
if(addr == null || s == null) return null;
|
||||||
try {
|
try {
|
||||||
|
s.setSoTimeout(0);
|
||||||
s.connect(addr);
|
s.connect(addr);
|
||||||
return new TcpTransportConnection(s);
|
return new TcpTransportConnection(s);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user