users@grizzly.java.net

Re: Grizzly & Comet concurrency issue

From: gustav trede <gustav.trede_wsdevel_at_telia.com>
Date: Mon, 27 Apr 2009 16:48:21 +0200

2009/4/27 FredrikJ <fredrik_at_robotsociety.com>

>
> I have made a small servlet that triggers this behavior, it can be found
> here: http://www.cubeia.com/docs/misc/NonSafeCometServlet.java
>

regarding your implementation:

 you dont need to flush the data for a notify in onEvent.
the resume / remove flushes,extra flush splits data into more then needed
number of tcp packages.

Onterminate should not try to remove the comethandler.
the onterminate is called after that the handler is removed.
onInterrupt should not remove the comethandler for similar reason.

In you remove the comethandler instead of resuming for notify, it has side
effects:
   onTerminate will never be called for that comethandler.
   the connection is leaked, client close and idle detection wont work.

you cant expect any cometcontext.notify to reach a comethandler before you
know that the handler.onInit has been called .
the handler is only made active after the servlet request is done.