changeset 7451:e5831ecc079b

8014254: Selector in HttpServer introduces a 1000 ms delay when using KeepAlive Summary: Rearrange event-handling code to remove bottle-neck. Also reviewed by mhall@mhcomputing.net. Reviewed-by: chegar, alanb
author khazra
date Mon, 13 May 2013 13:48:58 -0700
parents ffd8b8da0696
children 44ef857dd5e6
files src/share/classes/sun/net/httpserver/ServerImpl.java
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/net/httpserver/ServerImpl.java	Tue Mar 27 10:10:47 2012 -0700
+++ b/src/share/classes/sun/net/httpserver/ServerImpl.java	Mon May 13 13:48:58 2013 -0700
@@ -330,15 +330,7 @@
         public void run() {
             while (!finished) {
                 try {
-                    ListIterator<HttpConnection> li =
-                        connsToRegister.listIterator();
-                    for (HttpConnection c : connsToRegister) {
-                        reRegister(c);
-                    }
-                    connsToRegister.clear();
-
                     List<Event> list = null;
-                    selector.select(1000);
                     synchronized (lolock) {
                         if (events.size() > 0) {
                             list = events;
@@ -352,8 +344,14 @@
                         }
                     }
 
+                    for (HttpConnection c : connsToRegister) {
+                        reRegister(c);
+                    }
+                    connsToRegister.clear();
+
+                    selector.select(1000);
+
                     /* process the selected list now  */
-
                     Set<SelectionKey> selected = selector.selectedKeys();
                     Iterator<SelectionKey> iter = selected.iterator();
                     while (iter.hasNext()) {