Mark Galbreath wrote:
>
> Import the com.oreilly.servlet.DaemonHttpServlet class
> and extend it in your main class.
>

 The DaemonHttpServlet code looks a little iffy.

 DaemonHttpServlet.destroy() doesn't do the magic
'close the socket out from underneath the waiting
thread' trick, which means run() may not get knocked
out of waiting for accept() and the accept'ed Socket
isn't tracked at all, which means that handleClient
could block forever waiting for client input.

 Things get even more complicated when handleClient
needs to do any significant work, since then you have
to override destroy() to make sure it not only shuts
down the socket, but also anything else handleClient
might be waiting for. Plus, of course, the myriad of
possible race conditions if the servlet container
brings the servlet back to life while the old thread
is still shutting down.

 The whole point of defining a servlet lifecycle is
that it means the servlet container can worry about
all of that stuff for you. Clever tricks to get
around the 'problem' mean that _you_ are now
responsible for implementing all the tricky bits.

 Classes like DaemonHttpServlet are evil, because
they give newbies the false impression that they
don't need to worry, and get in the way of knowledgable
developers trying to do the right thing.

 Just say no :-)


 [1] See java.nio.channels.Channel javadoc referenced
in previous message (and assuming I'm looking at the
right version of the DaemonHttpServlet code)



--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to