--- apache-tomcat-6.0.26-src.orig/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-03-09 18:09:56.000000000 +0100 +++ apache-tomcat-6.0.26-src/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-04-12 14:13:26.000000000 +0200 @@ -906,6 +906,19 @@ log.debug("About to unlock socket for: " + saddr); } s.connect(saddr, unlockTimeout); + /* + * In the case of a deferred accept / accept filters we need to + * send data to wake up the accept. Send OPTIONS * to bypass even + * BSD accept filters. The Acceptor will discard it. + */ + if (deferAccept) { + PrintWriter pw; + + pw = new PrintWriter(s.getOutputStream()); + pw.print("OPTIONS * HTTP/1.0\r\n" + + "User-Agent: Tomcat wakeup connection\r\n\r\n"); + pw.flush(); + } } catch(Exception e) { if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.unlock", "" + port), e); @@ -1154,6 +1167,15 @@ try { // Accept the next incoming connection from the server socket long socket = Socket.accept(serverSock); + /* + * In the case of a deferred accept unlockAccept needs to + * send data. This data will be rubbish, so destroy the + * socket and don't process it. + */ + if (deferAccept && (paused || !running)) { + Socket.destroy(socket); + continue; + } // Hand this socket off to an appropriate processor if (!processSocketWithOptions(socket)) { // Close socket and pool right away