HttpTunnelServer should only check for disconnect after first connection

Previously, ServerThread would check for a disconnect as soon as it
had been started. This raced with it handling its first connection. If
the check for disconnect won the race it would incorrectly determine
that the disconnect timeout had been reached and wouldn’t respond to
the connection.

This commit updates ServerThread so that it only checks the disconnect
timeout once it’s handled at least one connection.

Closes gh-4668
pull/4684/head
Andy Wilkinson 9 years ago
parent 91674b2c94
commit df9308c645

@ -289,9 +289,12 @@ public class HttpTunnelServer {
}
private void checkNotDisconnected() {
long timeout = HttpTunnelServer.this.disconnectTimeout;
long duration = System.currentTimeMillis() - this.lastHttpRequestTime;
Assert.state(duration < timeout, "Disconnect timeout");
if (this.lastHttpRequestTime > 0) {
long timeout = HttpTunnelServer.this.disconnectTimeout;
long duration = System.currentTimeMillis() - this.lastHttpRequestTime;
Assert.state(duration < timeout,
"Disconnect timeout: " + timeout + " " + duration);
}
}
private void closeHttpConnections() {

Loading…
Cancel
Save