提交 515d813b 编写于 作者: K khazra

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
上级 2c93d30e
...@@ -321,15 +321,7 @@ class ServerImpl implements TimeSource { ...@@ -321,15 +321,7 @@ class ServerImpl implements TimeSource {
public void run() { public void run() {
while (!finished) { while (!finished) {
try { try {
ListIterator<HttpConnection> li =
connsToRegister.listIterator();
for (HttpConnection c : connsToRegister) {
reRegister(c);
}
connsToRegister.clear();
List<Event> list = null; List<Event> list = null;
selector.select(1000);
synchronized (lolock) { synchronized (lolock) {
if (events.size() > 0) { if (events.size() > 0) {
list = events; list = events;
...@@ -343,8 +335,14 @@ class ServerImpl implements TimeSource { ...@@ -343,8 +335,14 @@ class ServerImpl implements TimeSource {
} }
} }
/* process the selected list now */ for (HttpConnection c : connsToRegister) {
reRegister(c);
}
connsToRegister.clear();
selector.select(1000);
/* process the selected list now */
Set<SelectionKey> selected = selector.selectedKeys(); Set<SelectionKey> selected = selector.selectedKeys();
Iterator<SelectionKey> iter = selected.iterator(); Iterator<SelectionKey> iter = selected.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册