From: fhanik Date: Fri, 14 Jul 2006 05:14:31 +0000 (+0000) Subject: While this change made my linux box go faster, I could constantly crash my windows... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1da40183e6fd7a6d827831c79ae4b3905e668976;p=tomcat7.0 While this change made my linux box go faster, I could constantly crash my windows VM, so it will have to wait git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@421808 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 48278ae09..8301cbd6d 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -39,7 +39,6 @@ import org.apache.tomcat.jni.Poll; import org.apache.tomcat.jni.SSL; import org.apache.tomcat.jni.Status; import org.apache.tomcat.util.res.StringManager; -import java.util.concurrent.ConcurrentLinkedQueue; /** * NIO tailored thread pool, providing the following services: @@ -966,7 +965,7 @@ public class NioEndpoint { public class Poller implements Runnable { protected Selector selector; - protected ConcurrentLinkedQueue events = new ConcurrentLinkedQueue(); + protected LinkedList events = new LinkedList(); protected boolean close = false; protected long nextExpiration = 0;//optimize expiration handling @@ -1007,7 +1006,9 @@ public class NioEndpoint { } public void addEvent(Runnable event) { - events.add(event); + synchronized (events) { + events.add(event); + } selector.wakeup(); } @@ -1043,13 +1044,16 @@ public class NioEndpoint { } public void events() { - Runnable r = null; - while ( (events.size() > 0) && (r = events.poll()) != null ) { - try { - r.run(); - } catch ( Exception x ) { - log.error("",x); + synchronized (events) { + Runnable r = null; + while ( (events.size() > 0) && (r = events.removeFirst()) != null ) { + try { + r.run(); + } catch ( Exception x ) { + log.error("",x); + } } + events.clear(); } } @@ -1066,7 +1070,9 @@ public class NioEndpoint { } }; - events.add(r); + synchronized (events) { + events.add(r); + } selector.wakeup(); }