You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Reich, Matthias" <ma...@siemens.com> on 2007/05/30 14:04:08 UTC

Comet: Unsufficiently synchronized recycling decisions

Hi,

as mentioned in my contribution to topic 'Web application receives
request parameters sent to another application on Tomcat 6', I sometimes
get non-recycled Request objects in a BEGIN event. 

A non-recycled request object appeared in a BEGIN event if the previous
request processed by the same request processor was answered
asynchronously directly after the BEGIN event.

In such a situation my Servlet sometimes did not get an END event, i.e.
the CoyoteAdapter was not triggered again and therefore could not
recycle the Request object.
Nevertheless, the request processor was recycled, i.e. readded to the
processor pool.

As the processor was recycled, the cometEvent.close() must have happened
*after* CoyoteAdapter had made the decision not to recycle
Request/Response, but *before* Http11AprProtocol had made the decision
to recycle the processor.

To verify this, I modified the methods Http11AprProcessor.event and
Http11AprProcessor.process.

I replaced every occurrence of:

  recycle();

within these methods with the following lines:

  org.apache.catalina.connector.Request req =
(org.apache.catalina.connector.Request) request.getNote(1);
  org.apache.catalina.connector.Response res =
(org.apache.catalina.connector.Response) response.getNote(1);
  req.recycle( );
  res.recycle( );
  recycle();

I know that this is a hack and must be solved in a better way (and also
for the NIOConnector), but with these modifications I enforced a single
decision point for recycling of Request/Response *and* the processor.

When running Tomcat with these modifications, my Servlet no longer
received non-recycled Request objects.


Regards,
Matthias

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org