Fixed race where the key interests were set before updating the

state, causing onSelected() to be called with the wrong state and
failing an assertion.
This commit is contained in:
Simone Bordet 2014-09-26 10:12:42 +02:00
parent 8d2efaf7eb
commit bcbefd3942
1 changed files with 3 additions and 1 deletions

View File

@ -148,9 +148,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
case UPDATING:
{
// Set the key interest as expected.
setKeyInterests();
if (!_interestState.compareAndSet(current, State.SELECTING))
throw new IllegalStateException();
// Set the key interests after updating the state, otherwise
// the selector may select and call onSelected() concurrently.
setKeyInterests();
return;
}
case CHANGING: