提交 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 {
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;
......@@ -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();
Iterator<SelectionKey> iter = selected.iterator();
while (iter.hasNext()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册