tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From NormW <no...@bocnet.com.au>
Subject Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp_common.c jk_connect.c
Date Sat, 19 Feb 2005 09:27:35 GMT
Greetings,
Will see... :-)
N.

mturk@apache.org wrote:
> mturk       2005/02/19 01:13:35
> 
>   Modified:    jk/native/common jk_ajp_common.c jk_connect.c
>   Log:
>   Use alternative is_socket_connected implementation using
>   select with 1 microsecond timeout. It should be both faster and
>   usable on netware too.
>   
>   Revision  Changes    Path
>   1.91      +7 -9      jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c
>   
>   Index: jk_ajp_common.c
>   ===================================================================
>   RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c,v
>   retrieving revision 1.90
>   retrieving revision 1.91
>   diff -u -r1.90 -r1.91
>   --- jk_ajp_common.c	18 Feb 2005 08:27:21 -0000	1.90
>   +++ jk_ajp_common.c	19 Feb 2005 09:13:35 -0000	1.91
>   @@ -847,10 +847,9 @@
>                if (ae->worker->cache_timeout > 0 || ae->worker->recycle_timeout
> 0)
>                    ae->last_access = time(NULL);
>                if (ae->worker->socket_timeout > 0) {
>   -                int rc = 0;
>   -                if ((rc = jk_is_socket_connected(ae->sd, ae->worker->socket_timeout))
!= 1) {
>   -                        jk_log(l, JK_LOG_INFO,
>   -                            "Socket is not connected any more (status=%d)", rc);
>   +                if (!jk_is_socket_connected(ae->sd, ae->worker->socket_timeout))
{
>   +                    jk_log(l, JK_LOG_INFO,
>   +                           "Socket is not connected any more (errno=%d)", errno);
>                        jk_close_socket(ae->sd);
>                        ae->sd = -1;
>                        JK_TRACE_EXIT(l);
>   @@ -1161,10 +1160,9 @@
>        while ((ae->sd > 0)) {
>            err = 0;
>            if (ae->worker->socket_timeout) {
>   -            int rc = 0;
>   -            if ((rc = jk_is_socket_connected(ae->sd, ae->worker->socket_timeout))
!= 1) {
>   -                    jk_log(l, JK_LOG_INFO,
>   -                           "Socket is not connected any more (status=%d)", rc);
>   +            if (!jk_is_socket_connected(ae->sd, ae->worker->socket_timeout))
{
>   +                jk_log(l, JK_LOG_INFO,
>   +                       "Socket is not connected any more (errno=%d)", errno);
>                    jk_close_socket(ae->sd);
>                    ae->sd = -1;
>                    err++;
>   
>   
>   
>   1.43      +48 -2     jakarta-tomcat-connectors/jk/native/common/jk_connect.c
>   
>   Index: jk_connect.c
>   ===================================================================
>   RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_connect.c,v
>   retrieving revision 1.42
>   retrieving revision 1.43
>   diff -u -r1.42 -r1.43
>   --- jk_connect.c	17 Feb 2005 08:26:42 -0000	1.42
>   +++ jk_connect.c	19 Feb 2005 09:13:35 -0000	1.43
>   @@ -194,18 +194,36 @@
>                       sock_buf);
>        }
>    
>   -#ifdef WIN32
>        if (timeout > 0) {
>   +#ifdef WIN32
>            timeout = timeout * 1000;
>            setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
>                       (char *) &timeout, sizeof(int));
>            setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
>                       (char *) &timeout, sizeof(int));
>   +#else
>   +        /* TODO: How to set the timeout for other platforms? */
>   +#endif
>            if (JK_IS_DEBUG_LEVEL(l))
>                jk_log(l, JK_LOG_DEBUG,
>                       "timeout %d set for socket=%d",
>                       timeout, sock);
>        }
>   +#ifdef SO_NOSIGPIPE
>   +    /* The preferred method on Mac OS X (10.2 and later) to prevent SIGPIPEs when
>   +     * sending data to a dead peer. Possibly also existing and in use on other BSD
>   +     * systems?
>   +    */
>   +    set = 1;
>   +    if (setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (const char *)&set,
>   +                   sizeof(int))) {
>   +        JK_GET_SOCKET_ERRNO();
>   +        jk_log(l, JK_LOG_ERROR,
>   +                "failed setting SO_NOSIGPIPE with errno=%d", errno);
>   +        jk_close_socket(sock);
>   +        JK_TRACE_EXIT(l);
>   +        return -1;
>   +    }
>    #endif
>        /* Tries to connect to Tomcat (continues trying while error is EINTR) */
>        do {
>   @@ -405,6 +423,32 @@
>        return 0;
>    }
>    
>   +#if 1
>   +int jk_is_socket_connected(int sd, int timeout)
>   +{
>   +    fd_set fd;
>   +    struct timeval tv;
>   + 
>   +    FD_ZERO(&fd);
>   +    FD_SET(sd, &fd);
>   +
>   +    /* Wait one microsecond */
>   +    tv.tv_sec  = 0;
>   +    tv.tv_usec = 1;
>   +
>   +    /* If we get a timeout, then we are still connected */
>   +    if (select(1, &fd, NULL, NULL, &tv) == 0)
>   +        return 1;
>   +    else {
>   +#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
>   +        errno = WSAGetLastError() - WSABASEERR;
>   +#endif
>   +        return 0;
>   +    }
>   +}
>   +
>   +#else
>   +
>    #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
>    #define EWOULDBLOCK (WSAEWOULDBLOCK - WSABASEERR)
>    #endif
>   @@ -434,3 +478,5 @@
>        else
>            return rc;
>    }
>   +
>   +#endif
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 
> .
> 


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


Mime
View raw message