tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <>
Subject Re: 2 second delays in mod_jk while "maintaining workers"
Date Wed, 08 Sep 2010 16:33:11 GMT
On 09/08/2010 05:51 PM, John Baker wrote:
> I think it would be helpful if you could walk us through the code.

It is very simple actually.

1. shutdown write end of our connection to Tomcat
    This should cause the in Tomcat
    to throw exception which is used to close the socket
2. use poll with 2 second timeout for POLLIN event
    poll() will return immediately if either the
    socket is closed by Tomcat or there is a data
    to read in which case read to a dummy buffer (drain)
    and wait for more data until the poll returns
    error or read returns error
3. close the socket

So the reason why the poll breaks after 2 seconds
is the timeout which shouldn't happen because
we informed the Tomcat the our side of connection
is closed. So it should eventually (after some latency
depending on the CPU throttle close his side).

Now, since this works most of the times, it's either
that poll loop is running but the read returns 0

A simple debug message after
rc = read(sd, &dummy[0], sizeof(dummy));
jk_log(l, JK_LOG_DEBUG, "readed %d bytes from socked %d", rc, sd);

Would help eliminate that situation.
The fix would be to add
if (rc == 0) {
    rc = -1;

Also you can add
jk_log(l, JK_LOG_DEBUG, "socked %d shutdown write side", sd);
just before that 'do {' so we can have the info how long
the shutdown call took.

It would be helpful  if you can apply that code and


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message