Bug 49497 - Connector.pause() does not pause accepting request over keep-alive connections in Bio connector
Connector.pause() does not pause accepting request over keep-alive connection...
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Connectors
6.0.26
PC Windows XP
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-06-24 08:15 UTC by Konstantin Kolinko
Modified: 2010-11-03 15:03 UTC (History)
0 users



Attachments
Proposed patch (518 bytes, application/octet-stream)
2010-09-28 07:53 UTC, Mark Thomas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2010-06-24 08:15:31 UTC
When Tomcat performs shutdown, it pauses its connectors, then all web applications, and then stops the connectors.

In my understanding, pause() should stop Tomcat from accepting new requests from clients,  to give it time to complete requests that are currently being processed. The stop() call will close the sockets, and thus will abort request processing.


The problem is that the default (aka Bio) HTTP/1.1 connector of TC 6.0 behaves differently: when endpoint is paused, connector stops to accept new connections, but it still continues to accept new requests over existing keep-alive connections. I think it is not a feature, but a bug.

To reproduce:
1. Start Tomcat
2. Open http://localhost:8080/ in Firefox
3. Start jconsole, connect to Tomcat, select MBean for the Connector on port 8080 and invoke its pause() method.
4. Actual behaviour: In Firefox you can still open other pages of the web site, in spite of Connector being paused.

This issue does not affect Apr and Nio HTTP/1.1 connectors. In their case an attempt to navigate to another page of the site results in browser waiting for response from Tomcat.


To fix it, one has to modify the loop in Http11Processor#process() to check for the current value of endpoint.isPaused().

Caveat/separate issue: when the current Apr/Nio implementations are paused, they stop accepting the requests, but the keep-alive connection is still kept open. Maybe they should close the connection? On second thought, though, it makes a difference only if there is some load balancer in front of several Tomcats. Otherwise closing the connection will be just annoying, because a user will be tempted to immediately repeat the request, but Tomcat instance is still paused and will not be able to process it.

Tested with 6.0.27, WinXP, Firefox 3.6.4.

This bug report was inspired by the following comment in StandardService.stop():
// FIXME pero -- Why container stop first? KeepAlive connetions can send request!
Comment 1 Mark Thomas 2010-09-28 07:53:16 UTC
Created attachment 26094 [details]
Proposed patch
Comment 2 Mark Thomas 2010-11-03 15:03:16 UTC
Fixed in 6.0.x and will be included in 6.0.30 onwards.