From a0ec52da3321d09d06b2b59adac591d63d9330cc Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Tue, 10 Mar 2009 03:18:22 -0700 Subject: [PATCH] 6630639: lightweight HttpServer leaks file descriptors on no-data connections Not cleaning up no-data connections properly Reviewed-by: chegar --- jdk/src/share/classes/sun/net/httpserver/Request.java | 3 +++ jdk/src/share/classes/sun/net/httpserver/ServerImpl.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/jdk/src/share/classes/sun/net/httpserver/Request.java b/jdk/src/share/classes/sun/net/httpserver/Request.java index bdafe663c1b..02d240c989c 100644 --- a/jdk/src/share/classes/sun/net/httpserver/Request.java +++ b/jdk/src/share/classes/sun/net/httpserver/Request.java @@ -52,6 +52,9 @@ class Request { os = rawout; do { startLine = readLine(); + if (startLine == null) { + return; + } /* skip blank lines */ } while (startLine.equals ("")); } diff --git a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java index 104bdb0180b..919f7ce8ab6 100644 --- a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java +++ b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java @@ -441,6 +441,7 @@ class ServerImpl implements TimeSource { rawin = sslStreams.getInputStream(); rawout = sslStreams.getOutputStream(); engine = sslStreams.getSSLEngine(); + connection.sslStreams = sslStreams; } else { rawin = new BufferedInputStream( new Request.ReadStream ( @@ -450,6 +451,8 @@ class ServerImpl implements TimeSource { ServerImpl.this, chan ); } + connection.raw = rawin; + connection.rawout = rawout; } Request req = new Request (rawin, rawout); requestLine = req.requestLine();