mturk 2005/02/25 00:26:03 Modified: jk/native configure.in jk/native/common jk_connect.c Log: Add SO_RCVTIMEO for unixes. Revision Changes Path 1.39 +40 -3 jakarta-tomcat-connectors/jk/native/configure.in Index: configure.in =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/configure.in,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- configure.in 13 Feb 2005 13:05:15 -0000 1.38 +++ configure.in 25 Feb 2005 08:26:03 -0000 1.39 @@ -52,11 +52,48 @@ dnl check for snprintf and vsnprintf. AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,1,[Have snprintf()])) - AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF,1,[Have vsnprintf()])) - +dnl check for flock function. AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK,1,[Have flock()])) +AC_DEFUN(JK_CHECK_SETSOCKOPT, [ +AC_MSG_CHECKING(whether to use $1 with setsockopt()) +AC_TRY_RUN([ +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> + +int main(void) +{ + int s; + struct timeval tv; + tv.tv_sec = 3; + tv.tv_usec = 0; + +#ifndef $1 + exit(3); +#else + if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) + exit(2); + + /* fails on Solaris 2.6,8,9,10 and some Linuxes because + SO_RCVTIMEO|SO_SNDTIMEO are defined but not implemented */ + if (setsockopt(s, SOL_SOCKET, $1, (const void *)&tv, sizeof(tv)) == -1) + exit(1); + + exit(0); +#endif +} +] +, [ AC_MSG_RESULT([yes]) AC_DEFINE(USE_$1, 1, [Define to use $1 with setsockopt()]) ] +, [ AC_MSG_RESULT([no]) ] +) +])dnl + +dnl check for SO_RCVTIMEO and SO_SNDTIMEO +JK_CHECK_SETSOCKOPT(SO_RCVTIMEO) +JK_CHECK_SETSOCKOPT(SO_SNDTIMEO) + APACHE_CONFIG_VARS=`pwd`/scripts/build/config_vars.mk WEBSERVER="" apache_dir="" 1.46 +19 -9 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.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- jk_connect.c 21 Feb 2005 11:18:48 -0000 1.45 +++ jk_connect.c 25 Feb 2005 08:26:03 -0000 1.46 @@ -198,14 +198,20 @@ } if (timeout > 0) { -#ifdef WIN32 +#if defined(WIN32) timeout = timeout * 1000; setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, - (char *) &timeout, sizeof(int)); + (const char *) &timeout, sizeof(int)); setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, - (char *) &timeout, sizeof(int)); -#else - /* TODO: How to set the timeout for other platforms? */ + (const char *) &timeout, sizeof(int)); +#elif defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO) + struct timeval tv; + tv.tv_sec = timeout; + tv.tv_usec = 0; + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + (const void *) &tv, sizeof(tv)); + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + (const void *) &tv, sizeof(tv)); #endif if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, @@ -446,7 +452,8 @@ { fd_set fd; struct timeval tv; - + int rc; + FD_ZERO(&fd); FD_SET(sd, &fd); @@ -455,11 +462,14 @@ tv.tv_usec = 1; /* If we get a timeout, then we are still connected */ - if (select(1, &fd, NULL, NULL, &tv) == 0) + if ((rc = select(1, &fd, NULL, NULL, &tv)) == 0) return 1; else { #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) - errno = WSAGetLastError() - WSABASEERR; + if (rc == SOCKET_ERROR) + errno = WSAGetLastError() - WSABASEERR; + else + errno = 0; #endif return 0; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]