Skip to content

Commit

Permalink
jetty#5150 - Infinite connection timeout support in ManagedSelector
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Mozzhechkov <oleg.mozzhechkov@gmail.com>
  • Loading branch information
olegmoz committed Aug 13, 2020
1 parent 1b3cb2e commit bffd6a2
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -888,7 +888,11 @@ 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 +923,8 @@ 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 bffd6a2

Please sign in to comment.