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 soket.read() 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));
eg.
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;
   break;
}

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
recompile.


Regards
--
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to