Skip to content

Commit

Permalink
jetty#5150 - Infinite connection timeout support in ManagedSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
olegmoz committed Aug 13, 2020
1 parent 1b3cb2e commit df72e4b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
Expand Up @@ -888,7 +888,12 @@ class Connect implements SelectorUpdate, Runnable
{
this.channel = channel;
this.attachment = attachment;
this.timeout = ManagedSelector.this._selectorManager.getScheduler().schedule(this, ManagedSelector.this._selectorManager.getConnectTimeout(), TimeUnit.MILLISECONDS);
final long timeout = ManagedSelector.this._selectorManager.getConnectTimeout();
if (timeout > 0) {
this.timeout = ManagedSelector.this._selectorManager.getScheduler().schedule(this, timeout, TimeUnit.MILLISECONDS);
} else {
this.timeout = null;
}
}

@Override
Expand Down Expand Up @@ -919,7 +924,9 @@ public void failed(Throwable failure)
{
if (failed.compareAndSet(false, true))
{
timeout.cancel();
if (timeout != null) {
timeout.cancel();
}
IO.close(channel);
ManagedSelector.this._selectorManager.connectionFailed(channel, failure, attachment);
}
Expand Down

0 comments on commit df72e4b

Please sign in to comment.