Merge pull request #2705 from eclipse/jetty-9.4.x-2530-wakeup_selector_after_close

Fixes #2530 - Client waits forever for cancelled uploads.
This commit is contained in:
Simone Bordet 2018-07-11 12:02:27 +02:00 committed by GitHub
commit b46b8e7348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 3 deletions

View File

@ -101,7 +101,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
_selectorManager.execute(_strategy::produce);
// Set started only if we really are started
submit(s->_started.set(true));
submit(s->_started.set(true));
}
public int size()
@ -130,7 +130,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
stop_selector._stopped.await();
}
super.doStop();
super.doStop();
}
/**
@ -158,11 +158,30 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
if (selector != null)
{
if (LOG.isDebugEnabled())
LOG.debug("wakeup on submit {}", this);
LOG.debug("Wakeup on submit {}", this);
selector.wakeup();
}
}
private void wakeup()
{
if (LOG.isDebugEnabled())
LOG.debug("Wakeup {}", this);
Selector selector = null;
synchronized (ManagedSelector.this)
{
if (_selecting)
{
selector = _selector;
_selecting = false;
}
}
if (selector != null)
selector.wakeup();
}
private void execute(Runnable task)
{
try
@ -236,6 +255,10 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
public void destroyEndPoint(final EndPoint endPoint)
{
// Waking up the selector is necessary to clean the
// cancelled-key set and tell the TCP stack that the
// socket is closed (so that senders receive RST).
wakeup();
execute(new DestroyEndPoint(endPoint));
}