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
{
private static final Logger LOG = Log.getLogger(ManagedSelector.class);
private static final SelectorUpdate WAKEUP = new SelectorWakeup();
private final AtomicBoolean _started = new AtomicBoolean(false);
private boolean _selecting = false;
@ -101,7 +102,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 +131,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
stop_selector._stopped.await();
}
super.doStop();
super.doStop();
}
/**
@ -236,6 +237,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
public void destroyEndPoint(final EndPoint endPoint)
{
submit(WAKEUP);
execute(new DestroyEndPoint(endPoint));
}
@ -885,4 +887,18 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
run();
}
}
private static class SelectorWakeup implements SelectorUpdate
{
@Override
public void update(Selector selector)
{
}
@Override
public String toString()
{
return String.format("%s", getClass().getSimpleName());
}
}
}