https://bz.apache.org/bugzilla/show_bug.cgi?id=65311

            Bug ID: 65311
           Summary: NioBlockingSelector.BlockPoller.run() may not be
                    wakeup in time
           Product: Tomcat 8
           Version: 8.5.31
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: some51...@163.com
  Target Milestone: ----

org.apache.tomcat.util.net.NioBlockingSelector.BlockPoller: 

227  public void wakeup() {
228             if (wakeupCounter.addAndGet(1)==0) selector.wakeup();
229  }
....
287  public void run() {
288     while (run) {
289             try {
290                     events();
291                     int keyCount = 0;
292                     try {
293                             int i = wakeupCounter.get();
294                             if (i>0)
295                                     keyCount = selector.selectNow();
296                             else {
297                                     wakeupCounter.set(-1);
298                                     keyCount = selector.select(1000);
299                             }
300                             wakeupCounter.set(0);

when wakeupCounter is 0, selector.select(1000) may not be wakeup in time.
to resolve this bug, we can see org.apache.tomcat.util.net.NioEndpoint.Poller:

782  public void run() {
783     // Loop until destroy() is called
784     while (true) {
785  
786             boolean hasEvents = false;
787  
788             try {
789                     if (!close) {
790                             hasEvents = events();
791                             if (wakeupCounter.getAndSet(-1) > 0) {
792                                     //if we are here, means we have other
stuff to do
793                                     //do a non blocking select
794                                     keyCount = selector.selectNow();
795                             } else {
796                                     keyCount =
selector.select(selectorTimeout);
797                             }
798                             wakeupCounter.set(0);
799                     }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to