Issue #2755 - ManagedSelector 100% CPU spin.
Avoid race between doStart() and doStop() by waiting in doStart() for _started=true. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
a090741a60
commit
0a336230ef
|
@ -102,7 +102,9 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
|||
_selectorManager.execute(_strategy::produce);
|
||||
|
||||
// Set started only if we really are started
|
||||
submit(s->_started.set(true));
|
||||
Start start = new Start();
|
||||
submit(start);
|
||||
start._started.await();
|
||||
}
|
||||
|
||||
public int size()
|
||||
|
@ -540,6 +542,18 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
|||
public void update(Selector selector);
|
||||
}
|
||||
|
||||
private class Start implements SelectorUpdate
|
||||
{
|
||||
private final CountDownLatch _started = new CountDownLatch(1);
|
||||
|
||||
@Override
|
||||
public void update(Selector selector)
|
||||
{
|
||||
ManagedSelector.this._started.set(true);
|
||||
_started.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
private static class DumpKeys implements SelectorUpdate
|
||||
{
|
||||
private CountDownLatch latch = new CountDownLatch(1);
|
||||
|
|
Loading…
Reference in New Issue