Fixes #2530 - Client waits forever for cancelled uploads.

After discussion on openjdk/nio-dev, we now wakeup the selector
after closing a socket, so that the SelectionKey can be removed
from the Selector and the TCP stack notified that the socket
has been really closed, so that it can send RST to clients.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-07-09 10:02:45 +02:00
parent e03d16e59e
commit 0c8b33e581
1 changed files with 18 additions and 2 deletions

View File

@ -60,6 +60,7 @@ import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill;
public class ManagedSelector extends ContainerLifeCycle implements Dumpable public class ManagedSelector extends ContainerLifeCycle implements Dumpable
{ {
private static final Logger LOG = Log.getLogger(ManagedSelector.class); private static final Logger LOG = Log.getLogger(ManagedSelector.class);
private static final SelectorUpdate WAKEUP = new SelectorWakeup();
private final AtomicBoolean _started = new AtomicBoolean(false); private final AtomicBoolean _started = new AtomicBoolean(false);
private boolean _selecting = false; private boolean _selecting = false;
@ -236,6 +237,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
public void destroyEndPoint(final EndPoint endPoint) public void destroyEndPoint(final EndPoint endPoint)
{ {
submit(WAKEUP);
execute(new DestroyEndPoint(endPoint)); execute(new DestroyEndPoint(endPoint));
} }
@ -885,4 +887,18 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
run(); run();
} }
} }
private static class SelectorWakeup implements SelectorUpdate
{
@Override
public void update(Selector selector)
{
}
@Override
public String toString()
{
return String.format("%s", getClass().getSimpleName());
}
}
} }