tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastiaan van Erk <sebs...@sebster.com>
Subject Re: read data/infinite loop problem with comet
Date Tue, 26 Jun 2007 22:47:44 GMT
Hi,

Thanks for the suggestion. I already tried that fix, unfortunately it 
does not work. The problem is that even without those two lines, the 
event() method is not called again with a new READ event for the newly 
available data.

That said, the check seems wrong to me as well. If the servlet does not 
read all the data then I'm all for another call to the event() method.

Regards,
Sebastiaan

Reich, Matthias wrote:
> Hi,
>
> my feeling is that the CoyoteAdapter does a check that should not be
> done in this place (just because the implicit assumption is wrong that
> nothing will happen concurrently during the few nano seconds between the
> Servlet's available() check and the check of the adapter.)
>
> It looks as if the CoyoteAdapter code does not want to rely on the
> Servlet programmer to do the available() checks correctly and therefore
> tries to avoid loops of read events which could result from incorrect
> Servlet code.
>
> You could try to simply remove the lines 
>
>   
>>                 } else if (!error && read && request.getAvailable())
{
>>                     // If this was a read and not all bytes have been 
>> read, or if no data
>>                     // was read from the connector, then it 
>> is an error
>>                     error = true;
>>                     log.error(sm.getString("coyoteAdapter.read"));
>>                 }
>>     
>
> from the CoyoteAdapter code and run your Comet Servlet with the modified
> CoyoteAdapter.
>
> If it works, suggest this modification as a bug fix.
>
>
> Regards,
> Matthias
>
>   
>> -----Original Message-----
>> From: Sebastiaan van Erk [mailto:sebster@sebster.com] 
>> Sent: Tuesday, June 26, 2007 6:53 PM
>> To: Tomcat Users List
>> Subject: Re: read data/infinite loop problem with comet
>>
>> Hi all,
>>
>> I looked in the Tomcat source code (6.0.13), and I really do not 
>> understand how I'm supposed to avoid the following error:
>>
>> SEVERE: The servlet did not read all available bytes during the 
>> processing of the read event
>>
>> What seems to be happening is this:
>>
>> In my event method():
>>    while (request.getInputStream().available() > 0) {
>>       // read some data
>>    }
>>    // ***** NO MORE DATA AVAILABLE
>>    return;
>>
>> A bit later in CoyoteAdapter (187):
>>
>>                 // *** SOME DATA ARRIVES SOMEWHERE HERE
>>                 } else if (!error && read && request.getAvailable())
{
>>                     // If this was a read and not all bytes have been 
>> read, or if no data
>>                     // was read from the connector, then it 
>> is an error
>>                     error = true;
>>                     log.error(sm.getString("coyoteAdapter.read"));
>>                 }
>>                 return (!error);
>>
>> I checked the source code, and CoyoteInputStream.available() and 
>> Request.getAvailable() both return exactly the same value, namely 
>> InputBuffer.available(). So it seems that between my return and this 
>> check new data arrived has arrived, causing failure. What's worse, my 
>> CometProcessor does not get notified (I don't know why) of the error, 
>> and the Poller goes in an infinite loop.
>>
>> Does anybody know how I can solve this problem?
>>
>> Regards,
>> Sebastiaan
>>
>> Sebastiaan van Erk wrote:
>>     
>>> Hi,
>>>
>>> I'm having a problem reading data in my Comet servlet.
>>>
>>> In the BEGIN event I have the following loop:
>>>
>>>    while (request.getInputStream().available() > 0) {
>>>       // log that in read loop, log available()
>>>       // read some data
>>>    }
>>>    // log that read loop is done, log available()
>>>    return;
>>>
>>> However, even though I keep reading until available() 
>>>       
>> returns 0, I get 
>>     
>>> a SEVERE error complaining I did not read all the available data, 
>>> which can be seen from the following logs:
>>>
>>> 2007-06-26 14:37:08,427 DEBUG [http-8080-exec-4] 
>>> com.sebster.myservlet.TomcatCometServlet - BEGIN event for request 
>>> org.apache.catalina.connector.RequestFacade@d47c99
>>> 2007-06-26 14:37:08,427 DEBUG [http-8080-exec-4] 
>>> com.sebster.myservlet.TomcatCometServlet - 127.0.0.1:60578 POST 
>>> /mycometservlet
>>> 2007-06-26 14:37:08,432 DEBUG [http-8080-exec-4] 
>>> com.sebster.myservlet.TomcatCometServlet - 
>>> [24224039-a37e-40d0-a076-89d1df363390] read loop in BEGIN 
>>>       
>> event, input 
>>     
>>> stream data available: 1
>>> 2007-06-26 14:37:08,438 DEBUG [http-8080-exec-4] 
>>> com.sebster.myservlet.TomcatCometServlet - 
>>> [24224039-a37e-40d0-a076-89d1df363390] read loop done, input stream 
>>> data available: 0
>>> 2007-06-26 2:37:08.MD 
>>>       
>> org.apache.catalina.connector.CoyoteAdapter event
>>     
>>> SEVERE: The servlet did not read all available bytes during the 
>>> processing of the read event
>>>
>>> After this, the poller goes into an infinite event handling 
>>>       
>> busy loop.
>>     
>>> I looked at what the poller was doing, and it seems to be 
>>>       
>> setting the 
>>     
>>> comet event into the END event type and trying to call the event 
>>> method, however, it never arrives at my Comet processor's 
>>>       
>> event method 
>>     
>>> (it seems to call an event method on an error valve or though). I 
>>> don't know what exactly happens, but I can debug more if necessary.
>>>
>>> Does anybody know what the proper way to read ALL the data 
>>>       
>> is, and not 
>>     
>>> cause this exception to happen?
>>>
>>> Regards,
>>> Sebastiaan
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>>     
>>> 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
>>>
>>>       
>> ---------------------------------------------------------------------
>> 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
>>
>>
>>     
>
> ---------------------------------------------------------------------
> 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
>
>   

---------------------------------------------------------------------
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


Mime
View raw message