Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java')
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
index 8645e5edc5..6db2e74453 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
@@ -366,11 +366,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
if (_thread==Thread.currentThread())
{
// If we are already iterating over the changes, just add this change to the list.
- if (_state.get()==SelectorState.CHANGING)
+ // No race here because it is this thread that is iterating over the changes.
+ if (_state.compareAndSet(SelectorState.CHANGING,SelectorState.MORE_CHANGES))
_changes.offer(change);
else
{
- // Otherwise we run the queued changes, list should mostly be empty
+ // Otherwise we run the queued changes
runChanges();
// and then directly run the passed change
runChange(change);

Back to the top