Salut,
abeytom wrote:
>
> After debugging a little I found that in the method
> com.sun.grizzly.tcp.http11.GrizzlyOutputBuffer.realWriteBytes(byte[], int,
> int){
> if (closed)
> return;
> if (response == null)
> return;
>
> // If we really have something to write
> if (cnt > 0) {
> // real write to the adapter
> outputChunk.setBytes(buf, off, cnt);
> try {
> response.doWrite(outputChunk);
> } catch (IOException e) {
> // An IOException on a write is almost always due to
> // the remote client aborting the request. Wrap this
> // so that it can be handled better by the error dispatcher.
> throw new ClientAbortException(e);
> }
> }
> }
>
> The boolean flag closed is true, which causes the method to return without
> writing the data to output. In the above case it looks like this particular
> instance of GrizzlyOutputBuffer has been closed() earlier and is reused for
> another request.
if close == true it usually means the Response has been resumed. Do you
know if onInterrupt has been called before?
>
> In the method com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(Request,
> Response) ....
>
>
> GrizzlyRequest request = (GrizzlyRequest)
> req.getNote(ADAPTER_NOTES);
> GrizzlyResponse response = (GrizzlyResponse)
> res.getNote(ADAPTER_NOTES);
>
> if (request == null) {
> // Create objects
> request = new GrizzlyRequest();
> ............
> .............
> }
> else{
> response.getOutputBuffer().recycle();
> }
>
>
> I added the else part to recycle the OutputBuffer and now my code seems to
> be working fine. (I'm not sure of the other consequences of this change).
Usually recycling is invoked when GrizzlyAdapter.afterService() gets
invoked (as it recycle the Response object, which in turns recycle the
GrizzlyOutputBuffer.
Can you share a test case (publicly or privately ->
jfarcand_at_apache.org)? I want to understand when the GrizzlyOutputBuffer
gets closed. Usually the only way to close this object is when the
COmetHandler gets resumed, which internally means
GrizzlyAdapter.afterService() gets invoked.
Nice analysis BTW!
Thanks
-- Jeanfrancois
>
> Thanks
> Tom
> -------Original Message----------
>
> abeytom wrote:
>> Hi All,
>>
>> I have modified a the sample application grizzly-comet-chat from
>> trunk/code/samples run using grizzly-comet-webserver. I added a Timer to
>> the existing class com.sun.grizzly.samples.comet.AjaxCometServlet to push
>> the system-time to the client(browser). It works fine initially and if I
>> open 3 or 4 browsers and hit the refresh button on the broswer, that
>> browser stops getting responses. For debugging I'm sending a unique
>> clientId as a request param. Even if the browser didnt get any response ,
>> the server is logging(onEvent(..)) that its sending the response the to
>> the browser with that clientId. More over when I close the browser,
>> onInterrupt(..) method is getting invoked with the corrosponding clientId.
>> Just to make sure that its not a browser update issue, I used Charles Web
>> Debugging Proxy and saw that the request (GET) stream is open and i'm not
>> able to seen any responses from the server.
>> Also if I keep on opening new browsers, I get updates to the browser, but
>> if I close one browser and open a new one or refresh existing one, that
>> browser stop getting updates. All the existing ones get updates properly.
>> I have attached the source and the war file and environment details are
>> given below.
>> OS: Win XP
>> Browsers: Firefox 3.x, IE 7
>> Container: grizzly-comet-webserver-1.9.15-SNAPSHOT.jar - started by the
>> following command
>> java -jar
>> D:/Repository/svn/grizzly/trunk/code/modules/bundles/comet/target/grizzly-comet-webserver-1.9.15-SNAPSHOT.jar
>> -p 8181 -a target/grizzly-comet-chat.war
>> com.sun.grizzly.samples.comet.AjaxCometServlet
>> I'm using the code from latest trunk. I built all the jars in my machine
>> from the trunk code.
>>
>> Am I missing something, or I'm doing something wrong?
>>
>> Thank you for looking into this.
>> Tom
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>