Hi,

Thanks for the answer.

The problem is that available() returns 0 and I cannot be sure that I can do a read without blocking. I would prefer the internals of Tomcat handling this special case and calling the event method with a READ event on the Comet processor if there is already read data in the input buffer left after headers. This would be in line with the API. If available returns a positive number in BEGIN that would be fine as well, as long as I can be sure that I will never miss any data.

Another quick related question: is it possible for the event method to be called concurrently or does Tomcat prevent this? That is, do I need to synchronized access myself, or can I be sure that only one http thread is in the event method at a time?

Regards,
Sebastiaan

Filip Hanik - Dev Lists wrote:
Yes, this is an interesting use case, I usually issue a read on the BEGIN event. These events are IO related, ie, triggered by IO events and that is what they are. Since the data already has been read in with the request headers,
there will be no following IO event.
You could issue a read() in the BEGIN event, there is absolutely nothing wrong with doing that, as it is the same as a servlet doing a read during the service method.

Filip

Sebastiaan van Erk wrote:
Hi,

The CometProcessor seems to sometimes miss the initial READ event.

THE OBSERVED BEHAVIOR:
The client sends a request to the server. This request (a POST request) is sent in the initial TCP packet. The initial packet also contains some data (a boundary, Content-Disposition: form-data header, etc). The server gets a BEGIN request in which I do some setup; there is already data available for a READ event, but I don't get one. Meanwhile the client sends 10 more bytes of data to the server (which I see passing by in a TCP packet immediately after the request packet). However, I still get no READ event, instead I get a ERROR/TIMEOUT event a bunch later. If the client, instead of doing nothing, waits a couple of seconds and then sends some data, it does get a READ event server side and all the data is read (the boundary, the Content-Disposition header, etc).

Note this happens relatively infrequently, most of the time I do get the initial READ event.

The http://tomcat.apache.org/tomcat-6.0-doc/aio.html documentation clear states that I am not allowed to read from the input stream outside of the READ event; thus I'm not allowed to read in the BEGIN event. So the behavior I expect would be that I immediately get a READ event after the BEGIN event since there is data available.

I figure this is a bug?

Regards,
Sebastiaan

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





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


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

Reply via email to