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