You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jean-Jacques Clar <JJ...@novell.com> on 2005/05/20 19:56:37 UTC

JK shutdown problem

Hi,
 
file: jk_connect.c
in jk_shutdown_socket(); when reading data from tomcat in the while loop,
the variable ttl is incremented every time by one, until breaking out of the loop:
snippet: 
line 505 *-------------------------
    /* Read all data from the peer until we reach "end-of-file" (FIN
     * from peer) or we've exceeded our overall timeout. If the client does
     * not send us bytes within12 second, close the connection.
     */
    while (1) {
        nbytes = jk_tcp_socket_recvfull(s, dummy, sizeof(dummy));
        if (nbytes <= 0)
            break;
        ttl += SECONDS_TO_LINGER;
        if (ttl > MAX_SECS_TO_LINGER)
            break;
    
    }
end *----------------------
 
I don't see any linger time happening when calling recv(), in fact it returns immediately,
therefore the while will loop 16 times maximum instead of 16 seconds. This is causing
a problem on NetWare, where I have a socket still trying to send data for few more loops.
It will then cause an IO exception in Java.
Removing the break based on the number of loop fixes my problem.
Is the problem present for all platforms or this is only because of our
implementation of winsock?
The same code in apache ap_lingering_close() does not seem to cause problems, at least reported ones.
 
Thank you very much,
 
Jean-Jacques
 
 


Re: JK shutdown problem

Posted by Mladen Turk <mt...@apache.org>.
Jean-Jacques Clar wrote:
> Hi,
>  
> file: jk_connect.c
> in jk_shutdown_socket(); when reading data from tomcat in the while loop,
> the variable ttl is incremented every time by one, until breaking out of the loop:
> snippet: 
> line 505 *-------------------------
>     /* Read all data from the peer until we reach "end-of-file" (FIN
>      * from peer) or we've exceeded our overall timeout. If the client does
>      * not send us bytes within12 second, close the connection.
>      */
>     while (1) {
>         nbytes = jk_tcp_socket_recvfull(s, dummy, sizeof(dummy));
>         if (nbytes <= 0)
>             break;
>         ttl += SECONDS_TO_LINGER;
>         if (ttl > MAX_SECS_TO_LINGER)
>             break;
>     
>     }


The problem is because I do not have a Netware box.
You guys can try to enable the following:

#if defined(WIN32)
     setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
                (const char *) &tmout, sizeof(int));

#endif

for Netware too...
I didn't try to enable that because so many times the
JK has been broken because of Netware build bugs ;)

Also the code in nb_connect:
#if defined(WIN32)
         int tmout = timeout * 1000;
         setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
                    (const char *) &tmout, sizeof(int));
         setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
                    (const char *) &tmout, sizeof(int));
#else ...

Shuld be checked for: (probably but who knows ;)
for :
#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))


Regards,
Mladen

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org