Hi,

Due to the latest changes (r535030) to the Comet code I'm getting the AsyncCloseExceptions again, meaning that my synchronization which worked before is not correct anymore.

What I am doing is synchronizing all access to the response output stream and synchronizing with the same lock around event.close() in the event() method.

This is the stack trace I get in my async application code.

Caused by: java.nio.channels.AsynchronousCloseException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:185)
       at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:341)
       at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:111)
at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:57) at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:135) at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:130) at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:433) at org.apache.coyote.http11.InternalNioOutputBuffer.flushBuffer(InternalNioOutputBuffer.java:761) at org.apache.coyote.http11.InternalNioOutputBuffer.flush(InternalNioOutputBuffer.java:310) at org.apache.coyote.http11.Http11NioProcessor.action(Http11NioProcessor.java:1061)
       at org.apache.coyote.Response.action(Response.java:183)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314) at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288) at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:98) at com.sebster.comet.util.io.NoCloseOutputStream.flush(NoCloseOutputStream.java:36) at com.sebster.comet.util.io.AutoFlushingOutputStream.write(AutoFlushingOutputStream.java:31) at com.sebster.comet.util.io.SynchronizedOutputStream.write(SynchronizedOutputStream.java:29)

My application code writes a single byte to the response output stream and flushes it (the AutoFlushingOutputStream), which causes my client to close the socket. It seems that as a result of my client closing the socket, the output stream is closed on the Tomcat side as well, before my (synchronized) write finishes. This must happen outside of event.close() since I'm synchronizing around that as well. (BTW: the NoCloseOutputStream makes sure that a close() call in my async application code is not sent to the underlying output stream, and for the rest it just delegates).

What is the correct way to synchronize this in the new situation?

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]

Reply via email to