tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elias Naur" <elias.n...@gmail.com>
Subject Re: Tomcat 6 NIO connector/CometProcessor goes to 100% CPU usage
Date Fri, 06 Apr 2007 21:11:38 GMT
On 4/6/07, Filip Hanik - Dev Lists <devlists@hanik.com> wrote:
> Elias Naur wrote:
> > On 4/6/07, Rémy Maucherat <remy.maucherat@gmail.com> wrote:
> >> On 4/6/07, Elias Naur <elias.naur@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > I'm experimenting with the new tomcat 6 NIO connector to get a
> >> > CometProcessor servlet running. I've run into a problem that I hope
> >> > you guys can help me with. I'm testing a servlet that looks like this:
> >> >
> >> > public final class QueryEvent extends HttpServlet implements
> >> CometProcessor {
> >> >     public void event(CometEvent event) throws IOException,
> >> ServletException {
> >> >         System.out.println("event.getEventType() = " +
> >> event.getEventType());
> >> >     }
> >> > }
> >> >
> >> > that is, simply printing to std.out (catalina.out) whenever a comet
> >> > event arrives.  Then, I connect to the servlet with wget (or firefox,
> >> > same result) which immediately hangs, waiting for data. This is
> >> > expected, since I haven't sent anything back to the client, let alone
> >> > ended the connection. However, ending the connection by ctrl-c'ing
> >> > wget (or pressing stop in firefox) results in tomcat suddenly jumps
> >> > from almost no CPU usage to 100% usage until I kill it. I've included
> >> > a sample stack trace obtained with jstack while tomcat was at 100% CPU
> >> > usage.
> >> >
> >> > Some info:
> >> > 1. I'm running tomcat 6.0.10 on JDK 1.6
> >> > 2. Only one BEGIN event is seen by the event(CometEvent event) method,
> >> > no ERRORs or READs are received.
> >> > 3. The tomcat is running locally, so I've only seen this happen in the
> >> > loopback configuration, I don't know the behaviour when connecting to
> >> > a remote tomcat instance.
> >> > 4. No other connections to the tomcat instance is made while the test
> >> > is running.
> >>
> >> (testing on Windows with the APR connector)
> >> It of course does not behave the way you describe it: it does loop on
> >> a READ (on Windows).
> >>
> >> Rémy
> >>
> >
> > Oh, I'm sorry I didn't mention the OS. I'm running this on Ubuntu 6.10.
> in your case, the OS wouldn't matter, you need to empty the data, to
> avoid the spin
>
> Filip

Hi,

I'm aware that a correct implementation must empty the buffer on a
READ event, but as I stated in the original post, a READ event is
never received (not even when the client forces a disconnect), only
the initial BEGIN event, so had I included a read on READ it wouldn't
matter and would only serve to clutter the test case. If I'm supposed
to read when receiving BEGIN, I'll admit my test is incorrect, but
then the example at http://tomcat.apache.org/tomcat-6.0-doc/aio.html
needs to be corrected too.

 - elias
Mime
View raw message