cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/05/26 07:39:37 Modified:jk/native/common jk_connect.c Log: Add nonblocking detection for socket connections from pre 1.2.8 for non winsock platform. Also check for EAGAIN while reading data. Thanks to Kresimir Kukulj and his intensive testing for transient errors. Revision ChangesPath 1.60 +34 -7 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.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- jk_connect.c 13 May 2005 08:23:11 - 1.59 +++ jk_connect.c 26 May 2005 14:39:37 - 1.60 @@ -552,7 +552,7 @@ #else wr = write(sd, b + sent, len - sent); #endif -} while (wr == -1 errno == EINTR); +} while (wr == -1 (errno == EINTR || errno == EAGAIN)); if (wr == -1) return (errno 0) ? -errno : errno; @@ -587,7 +587,7 @@ #else rd = read(sd, (char *)b + rdlen, len - rdlen); #endif -} while (rd == -1 errno == EINTR); +} while (rd == -1 (errno == EINTR || errno == EAGAIN)); if (rd == -1) return (errno 0) ? -errno : errno; @@ -615,6 +615,7 @@ return buf; } +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) int jk_is_socket_connected(int sd) { fd_set fd; @@ -629,15 +630,41 @@ tv.tv_usec = 1; /* If we get a timeout, then we are still connected */ -if ((rc = select(1, fd, NULL, NULL, tv)) == 0) +if ((rc = select(1, fd, NULL, NULL, tv)) == 0) { +errno = 0; return 1; +} else { -#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if (rc == SOCKET_ERROR) errno = WSAGetLastError() - WSABASEERR; else -errno = 0; -#endif +errno = EOF; return 0; } } +#else +int jk_is_socket_connected(int sd) +{ +char test_buffer[1]; +int rd; +int saved_errno; + +errno = 0; +/* Set socket to nonblocking */ +if (sononblock(sd) != 0) +return 0; +do { +rd = read(sd, test_buffer, 1); +} while (rd == -1 errno == EINTR); +saved_errno = errno; +soblock(sd); +if (rd == -1 saved_errno == EWOULDBLOCK) { +errno = 0; +return 1; +} +else { +errno = saved_errno ? saved_errno : EOF; +return 0; +} +} +#endif - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
fuankg 2005/05/13 01:23:11 Modified:jk/native/common jk_connect.c Log: fix for NetWare compiler to deal with different types between AP13 and AP2 SDKs. Revision ChangesPath 1.59 +17 -6 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.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- jk_connect.c 27 Apr 2005 18:38:52 - 1.58 +++ jk_connect.c 13 May 2005 08:23:11 - 1.59 @@ -45,6 +45,13 @@ #define JK_GET_SOCKET_ERRNO() ((void)0) #endif /* WIN32 */ +/* our compiler cant deal with char* - const char* ... */ +#if defined(NETWARE) !defined(__NOVELL_LIBC__) +typedef char* SET_TYPE; +#else +typedef const char* SET_TYPE; +#endif + static int soblock(int sd) { /* BeOS uses setsockopt at present for non blocking... */ @@ -263,7 +270,11 @@ /* XXX : WARNING : We should really use gethostbyname_r in multi-threaded env */ /* Fortunatly when APR is available, ie under Apache 2.0, we use it */ +#if defined(NETWARE) !defined(__NOVELL_LIBC__) +struct hostent *hoste = gethostbyname((char*)host); +#else struct hostent *hoste = gethostbyname(host); +#endif if (!hoste) { return JK_FALSE; } @@ -305,7 +316,7 @@ return -1; } /* Disable Nagle algorithm */ -if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)set, +if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (SET_TYPE)set, sizeof(set))) { jk_log(l, JK_LOG_ERROR, failed setting TCP_NODELAY with errno=%d, errno); @@ -318,7 +329,7 @@ socket TCP_NODELAY set to On); if (keepalive) { set = 1; -if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (const char *)set, +if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (SET_TYPE)set, sizeof(set))) { jk_log(l, JK_LOG_ERROR, failed setting SO_KEEPALIVE with errno=%d, errno); @@ -334,7 +345,7 @@ if (sock_buf 0) { set = sock_buf; /* Set socket send buffer size */ -if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)set, +if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (SET_TYPE)set, sizeof(set))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, @@ -345,7 +356,7 @@ } set = sock_buf; /* Set socket receive buffer size */ -if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)set, +if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (SET_TYPE)set, sizeof(set))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, @@ -400,7 +411,7 @@ #ifdef SO_LINGER /* Make hard closesocket by disabling lingering */ li.l_linger = li.l_onoff = 0; -if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)li, +if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (SET_TYPE)li, sizeof(li))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/26 23:15:00 Modified:jk/native/common jk_connect.c Log: Add SD_SEND for platforms that has no such define. Also lower the lingering timeout for graceful shutdown to 1 second and maximum of 16x512 packets to consume, giving the AJP max packet size. Revision ChangesPath 1.55 +7 -5 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.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- jk_connect.c 24 Apr 2005 09:52:57 - 1.54 +++ jk_connect.c 27 Apr 2005 06:14:59 - 1.55 @@ -461,9 +461,12 @@ } #ifndef MAX_SECS_TO_LINGER -#define MAX_SECS_TO_LINGER 30 +#define MAX_SECS_TO_LINGER 16 +#endif +#define SECONDS_TO_LINGER 1 +#ifndef SD_SEND +#define DS_SEND 0x01 #endif -#define SECONDS_TO_LINGER 2 int jk_shutdown_socket(int s) { @@ -500,8 +503,7 @@ #endif /* 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 within 2 seconds (a value pulled from Apache 1.3 - * which seems to work well), close the connection. + * not send us bytes within12 second, close the connection. */ while (1) { nbytes = jk_tcp_socket_recvfull(s, dummy, sizeof(dummy)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/26 23:16:07 Modified:jk/native/common jk_connect.c Log: Fix typo. Revision ChangesPath 1.56 +2 -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.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- jk_connect.c 27 Apr 2005 06:14:59 - 1.55 +++ jk_connect.c 27 Apr 2005 06:16:07 - 1.56 @@ -465,7 +465,7 @@ #endif #define SECONDS_TO_LINGER 1 #ifndef SD_SEND -#define DS_SEND 0x01 +#define SD_SEND 0x01 #endif int jk_shutdown_socket(int s) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/26 23:18:11 Modified:jk/native/common jk_connect.c Log: No need to set the send timeout for read-only operation. Revision ChangesPath 1.57 +2 -6 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.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- jk_connect.c 27 Apr 2005 06:16:07 - 1.56 +++ jk_connect.c 27 Apr 2005 06:18:11 - 1.57 @@ -491,15 +491,11 @@ #if defined(WIN32) setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char *) tmout, sizeof(int)); -setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, - (const char *) tmout, sizeof(int)); -#elif defined(SO_RCVTIMEO) defined(USE_SO_RCVTIMEO) defined(SO_SNDTIMEO) defined(USE_SO_SNDTIMEO) +#elif defined(SO_RCVTIMEO) defined(USE_SO_RCVTIMEO) tv.tv_sec = SECONDS_TO_LINGER; tv.tv_usec = 0; setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const void *) tv, sizeof(tv)); -setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, - (const void *) tv, sizeof(tv)); #endif /* 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/27 11:38:52 Modified:jk/native/common jk_connect.c Log: Use SHUT_WR instead SD_SEND, to be more posix compilant. Revision ChangesPath 1.58 +9 -5 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.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- jk_connect.c 27 Apr 2005 06:18:11 - 1.57 +++ jk_connect.c 27 Apr 2005 18:38:52 - 1.58 @@ -464,10 +464,14 @@ #define MAX_SECS_TO_LINGER 16 #endif #define SECONDS_TO_LINGER 1 -#ifndef SD_SEND -#define SD_SEND 0x01 -#endif +#ifndef SHUT_WR +#ifdef SD_SEND +#define SHUT_WR SD_SEND +#else +#define SHUT_WR 0x01 +#endif +#endif int jk_shutdown_socket(int s) { unsigned char dummy[512]; @@ -485,7 +489,7 @@ /* Shut down the socket for write, which will send a FIN * to the peer. */ -if (shutdown(s, SD_SEND)) { +if (shutdown(s, SHUT_WR)) { return jk_close_socket(s); } #if defined(WIN32) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c jk_connect.h
mturk 2005/04/24 02:52:57 Modified:jk/native/common jk_connect.c jk_connect.h Log: Added jk_shutdown_socket function, that cracefully closes the AJP connection by sending FIN. Should help resolving WAIT_CLOSE sockets on some unixes. Revision ChangesPath 1.54 +56 -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.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- jk_connect.c 21 Apr 2005 11:36:29 - 1.53 +++ jk_connect.c 24 Apr 2005 09:52:57 - 1.54 @@ -460,6 +460,60 @@ return -1; } +#ifndef MAX_SECS_TO_LINGER +#define MAX_SECS_TO_LINGER 30 +#endif +#define SECONDS_TO_LINGER 2 + +int jk_shutdown_socket(int s) +{ +unsigned char dummy[512]; +int nbytes; +int ttl = 0; +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) +int tmout = SECONDS_TO_LINGER * 1000; +if (s == INVALID_SOCKET) +#else +struct timeval tv; +if (s 0) +#endif +return -1; + +/* Shut down the socket for write, which will send a FIN + * to the peer. + */ +if (shutdown(s, SD_SEND)) { +return jk_close_socket(s); +} +#if defined(WIN32) +setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, + (const char *) tmout, sizeof(int)); +setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, + (const char *) tmout, sizeof(int)); +#elif defined(SO_RCVTIMEO) defined(USE_SO_RCVTIMEO) defined(SO_SNDTIMEO) defined(USE_SO_SNDTIMEO) +tv.tv_sec = SECONDS_TO_LINGER; +tv.tv_usec = 0; +setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, + (const void *) tv, sizeof(tv)); +setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, + (const void *) tv, sizeof(tv)); +#endif +/* 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 within 2 seconds (a value pulled from Apache 1.3 + * which seems to work well), 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; +} +return jk_close_socket(s); +} + /** send a long message * @param sd opened socket. * @param b buffer containing the data. @@ -553,7 +607,7 @@ fd_set fd; struct timeval tv; int rc; - + FD_ZERO(fd); FD_SET(sd, fd); 1.15 +3 -1 jakarta-tomcat-connectors/jk/native/common/jk_connect.h Index: jk_connect.h === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_connect.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- jk_connect.h 21 Apr 2005 11:36:29 - 1.14 +++ jk_connect.h 24 Apr 2005 09:52:57 - 1.15 @@ -45,6 +45,8 @@ int jk_close_socket(int s); +int jk_shutdown_socket(int s); + int jk_tcp_socket_sendfull(int sd, const unsigned char *b, int len); int jk_tcp_socket_recvfull(int sd, unsigned char *b, int len); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/13 04:12:38 Modified:jk/native/common jk_connect.c Log: Fix typo -- missing printf format. Revision ChangesPath 1.52 +2 -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.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- jk_connect.c 11 Apr 2005 06:37:19 - 1.51 +++ jk_connect.c 13 Apr 2005 11:12:38 - 1.52 @@ -356,7 +356,7 @@ } if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - socket SO_SNDBUF and SO_RCVBUF set to d, + socket SO_SNDBUF and SO_RCVBUF set to %d, sock_buf); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/04/10 23:37:19 Modified:jk/native/common jk_connect.c Log: Fix compile warning about statement with no effect. Revision ChangesPath 1.51 +2 -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.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- jk_connect.c 18 Mar 2005 08:15:30 - 1.50 +++ jk_connect.c 11 Apr 2005 06:37:19 - 1.51 @@ -558,7 +558,7 @@ * If we change this to non blocking read, then we * will use the timeout parameter. */ - timeout; + timeout = 0; FD_ZERO(fd); FD_SET(sd, fd); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/03/18 00:15:30 Modified:jk/native/common jk_connect.c Log: Fix compile time warning about unused arg. Revision ChangesPath 1.50 +8 -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.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- jk_connect.c 17 Mar 2005 19:49:23 - 1.49 +++ jk_connect.c 18 Mar 2005 08:15:30 - 1.50 @@ -553,7 +553,13 @@ fd_set fd; struct timeval tv; int rc; - + +/* socket_timeout is unused in select implemention + * If we change this to non blocking read, then we + * will use the timeout parameter. + */ + timeout; + FD_ZERO(fd); FD_SET(sd, fd); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/03/17 11:41:58 Modified:jk/native/common jk_connect.c Log: Fix typo. We needed SO_SNDTIMEO here. Revision ChangesPath 1.48 +2 -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.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- jk_connect.c 15 Mar 2005 08:23:38 - 1.47 +++ jk_connect.c 17 Mar 2005 19:41:58 - 1.48 @@ -373,7 +373,7 @@ tv.tv_usec = 0; setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const void *) tv, sizeof(tv)); -setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, +setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const void *) tv, sizeof(tv)); #endif if (JK_IS_DEBUG_LEVEL(l)) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/03/17 11:49:23 Modified:jk/native/common jk_connect.c Log: WIN32 - do not change exiting var, because it is later used by nb_connect. Revision ChangesPath 1.49 +4 -4 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.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- jk_connect.c 17 Mar 2005 19:41:58 - 1.48 +++ jk_connect.c 17 Mar 2005 19:49:23 - 1.49 @@ -362,11 +362,11 @@ if (timeout 0) { #if defined(WIN32) -timeout = timeout * 1000; +int tmout = timeout * 1000; setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, - (const char *) timeout, sizeof(int)); + (const char *) tmout, sizeof(int)); setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, - (const char *) timeout, sizeof(int)); + (const char *) tmout, sizeof(int)); #elif defined(SO_RCVTIMEO) defined(USE_SO_RCVTIMEO) defined(SO_SNDTIMEO) defined(USE_SO_SNDTIMEO) struct timeval tv; tv.tv_sec = timeout; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/03/15 00:23:38 Modified:jk/native/common jk_connect.c Log: Add non blocking connect to Tomcat. It enables the true socket_timeout for connect call. Revision ChangesPath 1.47 +177 -77 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.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- jk_connect.c 25 Feb 2005 08:26:03 - 1.46 +++ jk_connect.c 15 Mar 2005 08:23:38 - 1.47 @@ -45,6 +45,169 @@ #define JK_GET_SOCKET_ERRNO() ((void)0) #endif /* WIN32 */ +static int soblock(int sd) +{ +/* BeOS uses setsockopt at present for non blocking... */ +#ifndef WIN32 +int fd_flags; + +fd_flags = fcntl(sd, F_GETFL, 0); +#if defined(O_NONBLOCK) +fd_flags = ~O_NONBLOCK; +#elif defined(O_NDELAY) +fd_flags = ~O_NDELAY; +#elif defined(FNDELAY) +fd_flags = ~FNDELAY; +#else +#error Please teach JK how to make sockets blocking on your platform. +#endif +if (fcntl(sd, F_SETFL, fd_flags) == -1) { +return errno; +} +#else +u_long on = 0; +if (ioctlsocket(sd, FIONBIO, on) == SOCKET_ERROR) { +errno = WSAGetLastError() - WSABASEERR; +return errno; +} +#endif /* WIN32 */ +return 0; +} + +static int sononblock(int sd) +{ +#ifndef WIN32 +int fd_flags; + +fd_flags = fcntl(sd, F_GETFL, 0); +#if defined(O_NONBLOCK) +fd_flags |= O_NONBLOCK; +#elif defined(O_NDELAY) +fd_flags |= O_NDELAY; +#elif defined(FNDELAY) +fd_flags |= FNDELAY; +#else +#error Please teach JK how to make sockets non-blocking on your platform. +#endif +if (fcntl(sd, F_SETFL, fd_flags) == -1) { +return errno; +} +#else +u_long on = 1; +if (ioctlsocket(sd, FIONBIO, on) == SOCKET_ERROR) { +errno = WSAGetLastError() - WSABASEERR; +return errno; +} +#endif /* WIN32 */ +return 0; +} + +#if defined (WIN32) +/* WIN32 implementation */ +static int nb_connect(int sock, struct sockaddr *addr, int timeout) +{ +int rc; +if (timeout 1) +return connect(sock, addr, sizeof(struct sockaddr_in)); + +if ((rc = sononblock(sock))) +return -1; +if (connect(sock, addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { +struct timeval tv; +fd_set wfdset, efdset; + +if ((rc = WSAGetLastError()) != WSAEWOULDBLOCK) { +soblock(sock); +WSASetLastError(rc); +return -1; +} +/* wait for the connect to complete or timeout */ +FD_ZERO(wfdset); +FD_SET(sock, wfdset); +FD_ZERO(efdset); +FD_SET(sock, efdset); + +tv.tv_sec = timeout; +tv.tv_usec = 0; +rc = select(FD_SETSIZE+1, NULL, wfdset, efdset, tv); +if (rc == SOCKET_ERROR || rc == 0) { +rc = WSAGetLastError(); +soblock(sock); +WSASetLastError(rc); +return -1; +} +/* Evaluate the efdset */ +if (FD_ISSET(sock, efdset)) { +/* The connect failed. */ +int rclen = sizeof(rc); +if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*) rc, rclen)) +rc = 0; +soblock(sock); +if (rc) +WSASetLastError(rc); +return -1; +} +} +soblock(sock); +return 0; +} + +#elif !defined(NETWARE) +/* POSIX implementation */ +static int nb_connect(int sock, struct sockaddr *addr, int timeout) +{ +int rc = 0; + +if (timeout 0) { +if (sononblock(sock)) +return -1; +} +do { +rc = connect(sock, addr, sizeof(struct sockaddr_in)); +} while (rc == -1 errno == EINTR); + +if ((rc == -1) (errno == EINPROGRESS || errno == EALREADY) +(timeout 0)) { +fd_set wfdset; +struct timeval tv; +int rclen = sizeof(rc); + +FD_ZERO(wfdset); +FD_SET(sock, wfdset); +tv.tv_sec = timeout; +tv.tv_usec = 0; +rc = select(sock+1, NULL, wfdset, NULL, tv); +if (rc = 0) { +/* Save errno */ +int err = errno; +soblock(sock); +errno = err; +return -1; +} +rc = 0; +#ifdef SO_ERROR +if (!FD_ISSET(sock, wfdset) || +(getsockopt(sock, SOL_SOCKET, SO_ERROR, +(char *)rc, rclen) 0) || rc) { +if (rc) +errno = rc; +rc = -1; +} +#endif /* SO_ERROR
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
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 ChangesPath 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 - 1.38 +++ configure.in 25 Feb 2005 08:26:03 - 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 - 1.45 +++ jk_connect.c 25 Feb 2005 08:26:03 - 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]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c jk_uri_worker_map.c
mturk 2005/02/21 03:18:48 Modified:jk/native/common jk_connect.c jk_uri_worker_map.c Log: Remove unused code. Revision ChangesPath 1.45 +4 -36 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.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- jk_connect.c 20 Feb 2005 08:15:33 - 1.44 +++ jk_connect.c 21 Feb 2005 11:18:48 - 1.45 @@ -382,6 +382,7 @@ return buf; } +#if 0 static int soblock(int sd) { /* BeOS uses setsockopt at present for non blocking... */ @@ -439,7 +440,8 @@ return 0; } -#if 1 +#endif + int jk_is_socket_connected(int sd, int timeout) { fd_set fd; @@ -462,37 +464,3 @@ return 0; } } - -#else - -#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) -#define EWOULDBLOCK (WSAEWOULDBLOCK - WSABASEERR) -#endif - -int jk_is_socket_connected(int sd, int timeout) -{ -unsigned char test_buffer[1]; -int rc; -/* Set socket to nonblocking */ -if ((rc = sononblock(sd)) != 0) -return (errno 0) ? -errno : errno; - -rc = jk_tcp_socket_recvfull(sd, test_buffer, 1) * (-1); -soblock(sd); -#ifdef WIN32 -/* Reset socket timeouts if the new timeout differs from the old timeout */ -if (timeout 0) { -/* Timeouts are in msec, represented as int */ -setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, -(char *) timeout, sizeof(int)); -setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, -(char *) timeout, sizeof(int)); -} -#endif -if (rc == EWOULDBLOCK || rc == -1) -return 1; -else -return rc; -} - -#endif 1.50 +4 -5 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c Index: jk_uri_worker_map.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- jk_uri_worker_map.c 21 Feb 2005 08:27:13 - 1.49 +++ jk_uri_worker_map.c 21 Feb 2005 11:18:48 - 1.50 @@ -136,7 +136,7 @@ { JK_TRACE_ENTER(l); -if (init_data uw_map) { +if (uw_map) { int rc; *uw_map = (jk_uri_worker_map_t *)calloc(1, sizeof(jk_uri_worker_map_t)); @@ -148,8 +148,8 @@ JK_TRACE_EXIT(l); return JK_FALSE; } - -rc = uri_worker_map_open(*uw_map, init_data, l); +if (init_data) +rc = uri_worker_map_open(*uw_map, init_data, l); JK_TRACE_EXIT(l); return rc; } @@ -234,7 +234,6 @@ char *uri; unsigned int match_type = 0; unsigned int i; -int allocated = 0; JK_TRACE_ENTER(l); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/02/20 00:15:33 Modified:jk/native/common jk_connect.c Log: Disable lingering on socket. This way the socket will be hard closed without waiting for delivery of remaining data. Revision ChangesPath 1.44 +19 -3 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.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- jk_connect.c 19 Feb 2005 09:13:35 - 1.43 +++ jk_connect.c 20 Feb 2005 08:15:33 - 1.44 @@ -126,7 +126,10 @@ char buf[32]; int sock; int set = 1; -int ret; +int ret = 0; +#ifdef SO_LINGER +struct linger li; +#endif JK_TRACE_ENTER(l); @@ -215,7 +218,7 @@ * systems? */ set = 1; -if (setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (const char *)set, +if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (const char *)set, sizeof(int))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, @@ -225,6 +228,19 @@ return -1; } #endif +#ifdef SO_LINGER +/* Make hard closesocket by disabling lingering */ +li.l_linger = li.l_onoff = 0; +if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)li, + sizeof(li))) { +JK_GET_SOCKET_ERRNO(); +jk_log(l, JK_LOG_ERROR, +failed setting SO_LINGER 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 { if (JK_IS_DEBUG_LEVEL(l)) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/02/17 00:10:41 Modified:jk/native/common jk_connect.c Log: Use provided socket_buffer size instead 8K default if set. Revision ChangesPath 1.41 +8 -4 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.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- jk_connect.c 17 Feb 2005 07:09:27 - 1.40 +++ jk_connect.c 17 Feb 2005 08:10:40 - 1.41 @@ -165,8 +165,8 @@ socket SO_KEEPALIVE set to On); } -if (sock_buf) { -set = DEF_BUFFER_SZ; +if (sock_buf 0) { +set = sock_buf; /* Set socket send buffer size */ if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)set, sizeof(set))) { @@ -177,7 +177,7 @@ JK_TRACE_EXIT(l); return -1; } -set = DEF_BUFFER_SZ; +set = sock_buf; /* Set socket receive buffer size */ if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)set, sizeof(set))) { @@ -188,6 +188,10 @@ JK_TRACE_EXIT(l); return -1; } +if (JK_IS_DEBUG_LEVEL(l)) +jk_log(l, JK_LOG_DEBUG, + socket SO_SNDBUF and SO_RCVBUF set to d, + sock_buf); } #ifdef WIN32 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2005/02/17 00:26:42 Modified:jk/native/common jk_connect.c Log: Remove the CRLFs. Again. Revision ChangesPath 1.42 +14 -14jakarta-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.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- jk_connect.c 17 Feb 2005 08:10:40 - 1.41 +++ jk_connect.c 17 Feb 2005 08:26:42 - 1.42 @@ -71,7 +71,7 @@ #ifdef HAVE_APR apr_sockaddr_t *remote_sa, *temp_sa; char *remote_ipaddr; - + if (!jk_apr_pool) { if (apr_pool_create(jk_apr_pool, NULL) != APR_SUCCESS) return JK_FALSE; @@ -197,9 +197,9 @@ #ifdef WIN32 if (timeout 0) { timeout = timeout * 1000; -setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, +setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *) timeout, sizeof(int)); -setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, +setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *) timeout, sizeof(int)); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, @@ -214,13 +214,13 @@ trying to connect socket %d to %s, sock, jk_dump_hinfo(addr, buf)); -/* Need more infos for BSD 4.4 and Unix 98 defines, for now only +/* Need more infos for BSD 4.4 and Unix 98 defines, for now only iSeries when Unix98 is required at compil time */ #if (_XOPEN_SOURCE = 520) defined(AS400) ((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in); #endif ret = connect(sock, (struct sockaddr *)addr, - sizeof(struct sockaddr_in)); + sizeof(struct sockaddr_in)); #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if (ret == SOCKET_ERROR) { errno = WSAGetLastError() - WSABASEERR; @@ -318,10 +318,10 @@ if (rd == SOCKET_ERROR) errno = WSAGetLastError() - WSABASEERR; #else -rd = read(sd, (char *)b + rdlen, len - rdlen); +rd = read(sd, (char *)b + rdlen, len - rdlen); #endif } while (rd == -1 errno == EINTR); - + if (rd == -1) return (errno 0) ? -errno : errno; else if (rd == 0) @@ -403,7 +403,7 @@ } #endif /* WIN32 */ return 0; -} +} #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) #define EWOULDBLOCK (WSAEWOULDBLOCK - WSABASEERR) @@ -411,8 +411,8 @@ int jk_is_socket_connected(int sd, int timeout) { -unsigned char test_buffer[1]; -int rc; +unsigned char test_buffer[1]; +int rc; /* Set socket to nonblocking */ if ((rc = sononblock(sd)) != 0) return (errno 0) ? -errno : errno; @@ -423,11 +423,11 @@ /* Reset socket timeouts if the new timeout differs from the old timeout */ if (timeout 0) { /* Timeouts are in msec, represented as int */ -setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, +setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char *) timeout, sizeof(int)); -setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, +setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, (char *) timeout, sizeof(int)); -} +} #endif if (rc == EWOULDBLOCK || rc == -1) return 1; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c jk_connect.h
mturk 2005/02/16 23:09:27 Modified:jk/native/common jk_connect.c jk_connect.h Log: Remove socket_timeout settings except for WIN32 platforms. Also add nonblocking is_connected function. Unlike cping/cpong this one checks the physical condition of the wire. Revision ChangesPath 1.40 +128 -143 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.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- jk_connect.c 16 Feb 2005 15:28:28 - 1.39 +++ jk_connect.c 17 Feb 2005 07:09:27 - 1.40 @@ -33,6 +33,8 @@ #include apr_network_io.h #include apr_errno.h #include apr_general.h +#include apr_pools.h +static apr_pool_t *jk_apr_pool = NULL; #endif #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) @@ -57,7 +59,7 @@ rc-sin_family = AF_INET; /* Check if we only have digits in the string */ -for (x = 0; '\0' != host[x]; x++) { +for (x = 0; host[x] != '\0'; x++) { if (!isdigit(host[x]) host[x] != '.') { break; } @@ -67,16 +69,15 @@ if (host[x] != '\0') { #ifdef HAVE_APR -apr_pool_t *context; apr_sockaddr_t *remote_sa, *temp_sa; char *remote_ipaddr; - -/* May be we could avoid to recreate it each time ? */ -if (apr_pool_create(context, NULL) != APR_SUCCESS) -return JK_FALSE; - + +if (!jk_apr_pool) { +if (apr_pool_create(jk_apr_pool, NULL) != APR_SUCCESS) +return JK_FALSE; +} if (apr_sockaddr_info_get -(remote_sa, host, APR_UNSPEC, (apr_port_t) port, 0, context) +(remote_sa, host, APR_UNSPEC, (apr_port_t) port, 0, jk_apr_pool) != APR_SUCCESS) return JK_FALSE; @@ -95,9 +96,6 @@ apr_sockaddr_ip_get(remote_ipaddr, remote_sa); laddr.s_addr = inet_addr(remote_ipaddr); -/* May be we could avoid to delete it each time ? */ -apr_pool_destroy(context); - #else /* HAVE_APR */ /* XXX : WARNING : We should really use gethostbyname_r in multi-threaded env */ @@ -122,114 +120,123 @@ /** connect to Tomcat */ -int jk_open_socket(struct sockaddr_in *addr, - int keepalive, int timeout, jk_logger_t *l) +int jk_open_socket(struct sockaddr_in *addr, int keepalive, + int timeout, int sock_buf, jk_logger_t *l) { char buf[32]; int sock; int set = 1; +int ret; JK_TRACE_ENTER(l); sock = socket(AF_INET, SOCK_STREAM, 0); -if (sock = 0) { -int ret, len; -if (timeout != -1) { -/* do not allow non blocking sockets for now */ -if (timeout == 0) -timeout = -1; -ret = jk_socket_timeout_set(sock, -1, timeout * 1000); -if (ret) { -jk_close_socket(sock); -jk_log(l, JK_LOG_ERROR, - timeout_set failed with errno = %d, - ret); -JK_TRACE_EXIT(l); -return -1; -} -if (JK_IS_DEBUG_LEVEL(l)) -jk_log(l, JK_LOG_DEBUG, - set timeout to %d with status %d, - timeout, ret); - -} - -/* Tries to connect to Tomcat (continues trying while error is EINTR) */ -do { -if (JK_IS_DEBUG_LEVEL(l)) -jk_log(l, JK_LOG_DEBUG, - try to connect socket = %d to %s, sock, - jk_dump_hinfo(addr, buf)); - -/* Need more infos for BSD 4.4 and Unix 98 defines, for now only - iSeries when Unix98 is required at compil time */ -#if (_XOPEN_SOURCE = 520) defined(AS400) -((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in); -#endif -ret = connect(sock, - (struct sockaddr *)addr, - sizeof(struct sockaddr_in)); -#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) -if (SOCKET_ERROR == ret) { -errno = WSAGetLastError() - WSABASEERR; -} -#endif /* WIN32 */ -if (JK_IS_DEBUG_LEVEL(l)) -jk_log(l, JK_LOG_DEBUG, - after connect ret = %d, ret); -} while (-1 == ret EINTR == errno); - -/* Check if we connected */ -if (ret == -1) { -jk_log(l, JK_LOG_INFO, - connect() failed errno = %d, errno); +if (sock 0) {
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/12/23 00:09:07 Modified:jk/native/common jk_connect.c Log: Fix in_addr problems using real structure. Patch provided by wrowe. Thanks Bill. Revision ChangesPath 1.36 +5 -17 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.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- jk_connect.c 17 Dec 2004 14:58:37 - 1.35 +++ jk_connect.c 23 Dec 2004 08:09:07 - 1.36 @@ -35,10 +35,6 @@ #include apr_general.h #endif -#if defined(WIN32) -typedef u_long in_addr_t; -#endif - #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) #define JK_IS_SOCKET_ERROR(x) ((x) == SOCKET_ERROR) #define JK_GET_SOCKET_ERRNO() errno = WSAGetLastError() - WSABASEERR @@ -53,15 +49,7 @@ int jk_resolve(char *host, int port, struct sockaddr_in *rc) { int x; - -/* TODO: Should be updated for IPV6 support. */ -/* for now use the correct type, in_addr_t */ -/* except on NetWare since the MetroWerks compiler is so strict */ -#if defined(NETWARE) -u_long laddr; -#else -in_addr_t laddr; -#endif +struct in_addr laddr; memset(rc, 0, sizeof(struct sockaddr_in)); @@ -105,7 +93,7 @@ return JK_FALSE; apr_sockaddr_ip_get(remote_ipaddr, remote_sa); -laddr = inet_addr(remote_ipaddr); +laddr.s_addr = inet_addr(remote_ipaddr); /* May be we could avoid to delete it each time ? */ apr_pool_destroy(context); @@ -119,13 +107,13 @@ return JK_FALSE; } -laddr = ((struct in_addr *)hoste-h_addr_list[0])-s_addr; +laddr = *((struct in_addr *)hoste-h_addr_list[0]); #endif /* HAVE_APR */ } else { /* If we found only digits we use inet_addr() */ -laddr = inet_addr(host); +laddr.s_addr = inet_addr(host); } memcpy((rc-sin_addr), laddr, sizeof(laddr)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/12/13 06:05:15 Modified:jk/native/common jk_connect.c Log: Fix zero socket_timeout. We do not support nonblocking sockets for now. This is only observed if someone sets socket_timeout to zero. Revision ChangesPath 1.32 +4 -1 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.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- jk_connect.c 11 Nov 2004 18:34:36 - 1.31 +++ jk_connect.c 13 Dec 2004 14:05:15 - 1.32 @@ -146,6 +146,9 @@ if (sock = 0) { int ret, len; if (timeout != -1) { +/* do not allow non blocking sockets for now */ +if (timeout == 0) +timeout = 60 * 100; ret = jk_socket_timeout_set(sock, -1, timeout); if (ret) { jk_close_socket(sock); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/12/13 06:26:36 Modified:jk/native/common jk_connect.c Log: Use infinite timeout if socket_timeout is set to zero. Revision ChangesPath 1.33 +2 -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.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- jk_connect.c 13 Dec 2004 14:05:15 - 1.32 +++ jk_connect.c 13 Dec 2004 14:26:36 - 1.33 @@ -148,7 +148,7 @@ if (timeout != -1) { /* do not allow non blocking sockets for now */ if (timeout == 0) -timeout = 60 * 100; +timeout = -1; ret = jk_socket_timeout_set(sock, -1, timeout); if (ret) { jk_close_socket(sock); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/12/13 06:43:41 Modified:jk/native/common jk_connect.c Log: Transform the config value to milliseconds. Revision ChangesPath 1.34 +3 -3 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.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- jk_connect.c 13 Dec 2004 14:26:36 - 1.33 +++ jk_connect.c 13 Dec 2004 14:43:41 - 1.34 @@ -148,8 +148,8 @@ if (timeout != -1) { /* do not allow non blocking sockets for now */ if (timeout == 0) -timeout = -1; -ret = jk_socket_timeout_set(sock, -1, timeout); +timeout = -1; +ret = jk_socket_timeout_set(sock, -1, timeout * 1000); if (ret) { jk_close_socket(sock); jk_log(l, JK_LOG_ERROR, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/11/11 10:34:36 Modified:jk/native/common jk_connect.c Log: Add new trace macros and clean up some log messages. Revision ChangesPath 1.31 +15 -11jakarta-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.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- jk_connect.c 10 Nov 2004 16:36:48 - 1.30 +++ jk_connect.c 11 Nov 2004 18:34:36 - 1.31 @@ -149,13 +149,14 @@ ret = jk_socket_timeout_set(sock, -1, timeout); if (ret) { jk_close_socket(sock); -jk_log(l, JK_LOG_INFO, - jk_open_socket, timeout_set failed errno = %d\n, +jk_log(l, JK_LOG_ERROR, + timeout_set failed with errno = %d\n, ret); +JK_TRACE_EXIT(l); return -1; } jk_log(l, JK_LOG_DEBUG, -jk_open_socket, set timeout to %d with status %d\n, +set timeout to %d with status %d\n, timeout, ret); } @@ -163,7 +164,7 @@ /* Tries to connect to Tomcat (continues trying while error is EINTR) */ do { jk_log(l, JK_LOG_DEBUG, - jk_open_socket, try to connect socket = %d to %s\n, sock, + try to connect socket = %d to %s\n, sock, jk_dump_hinfo(addr, buf)); /* Need more infos for BSD 4.4 and Unix 98 defines, for now only @@ -180,14 +181,15 @@ } #endif /* WIN32 */ jk_log(l, JK_LOG_DEBUG, - jk_open_socket, after connect ret = %d\n, ret); + after connect ret = %d\n, ret); } while (-1 == ret EINTR == errno); /* Check if we connected */ if (ret == -1) { jk_log(l, JK_LOG_INFO, - jk_open_socket, connect() failed errno = %d\n, errno); + connect() failed errno = %d\n, errno); jk_close_socket(sock); +JK_TRACE_EXIT(l); return -1; } if (ndelay) { @@ -211,8 +213,9 @@ sizeof(len))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, - ERROR: jk_open_socket, failed setting sndbuf errno = %d\n, errno); + failed setting sndbuf errno = %d\n, errno); jk_close_socket(sock); +JK_TRACE_EXIT(l); return -1; } /* Set socket receive buffer size */ @@ -220,18 +223,19 @@ sizeof(len))) { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, - ERROR: jk_open_socket, failed setting rcvbuf errno = %d\n, errno); + failed setting rcvbuf errno = %d\n, errno); jk_close_socket(sock); +JK_TRACE_EXIT(l); return -1; } -jk_log(l, JK_LOG_DEBUG, jk_open_socket, return, sd = %d\n, +jk_log(l, JK_LOG_DEBUG, connected sd = %d\n, sock); } else { JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, - jk_open_socket, socket() failed errno = %d\n, errno); + socket() failed with errno = %d\n, errno); } JK_TRACE_EXIT(l); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c jk_lb_worker.c jk_logger.h jk_msg_buff.c jk_pool.c jk_uri_worker_map.c jk_worker.c
mturk 2004/11/10 08:28:31 Modified:jk/native/common jk_connect.c jk_lb_worker.c jk_logger.h jk_msg_buff.c jk_pool.c jk_uri_worker_map.c jk_worker.c Log: Use new TRACE macros and __FUNCTION__ builtins Revision ChangesPath 1.29 +3 -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.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- jk_connect.c 8 Nov 2004 13:39:27 - 1.28 +++ jk_connect.c 10 Nov 2004 16:28:31 - 1.29 @@ -140,7 +140,7 @@ char buf[32]; int sock; -jk_log(l, JK_LOG_DEBUG, Into jk_open_socket\n); + JK_TRACE_ENTER(l); sock = socket(AF_INET, SOCK_STREAM, 0); if (sock = 0) { @@ -234,6 +234,7 @@ jk_open_socket, socket() failed errno = %d\n, errno); } + JK_TRACE_EXIT(l); return sock; } 1.26 +44 -54jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c Index: jk_lb_worker.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- jk_lb_worker.c8 Nov 2004 13:42:23 - 1.25 +++ jk_lb_worker.c10 Nov 2004 16:28:31 - 1.26 @@ -274,7 +274,7 @@ jk_ws_service_t *s, jk_logger_t *l, int *is_recoverable_error) { -jk_log(l, JK_LOG_DEBUG, Into jk_endpoint_t::service\n); + JK_TRACE_ENTER(l); if (e e-endpoint_private s is_recoverable_error) { lb_endpoint_t *p = e-endpoint_private; @@ -290,7 +290,7 @@ jk_b_reset(s-reco_buf); s-reco_status = RECO_INITED; jk_log(l, JK_LOG_DEBUG, - Into jk_endpoint_t::service sticky_session=%d\n, + __FUNCTION__ ::service sticky_session=%d\n, p-worker-sticky_session); while (1) { @@ -305,8 +305,8 @@ rc = rec-w-get_endpoint(rec-w, end, l); -jk_log(l, JK_LOG_INFO, - Into jk_endpoint_t::service worker=%s jvm_route=%s rc=%d\n, +jk_log(l, JK_LOG_DEBUG, + __FUNCTION__ ::service worker=%s jvm_route=%s rc=%d\n, rec-name, s-jvm_route, rc); if (rc end) { @@ -316,6 +316,7 @@ rec-in_error_state = JK_FALSE; rec-in_recovering = JK_FALSE; rec-error_time = 0; + JK_TRACE_EXIT(l); return JK_TRUE; } } @@ -344,7 +345,7 @@ * another worker... Lets try to do that. */ jk_log(l, JK_LOG_DEBUG, - lb: recoverable error... will try to recover on other host\n); +__FUNCTION__ ::recoverable error... will try to recover on other host\n); } else { /* NULL record, no more workers left ... */ @@ -357,13 +358,12 @@ } jk_log(l, JK_LOG_ERROR, lb: end of service with error\n); - return JK_FALSE; } static int JK_METHOD done(jk_endpoint_t **e, jk_logger_t *l) { -jk_log(l, JK_LOG_DEBUG, Into jk_endpoint_t::done\n); + JK_TRACE_ENTER(l); if (e *e (*e)-endpoint_private) { lb_endpoint_t *p = (*e)-endpoint_private; @@ -374,10 +374,11 @@ free(p); *e = NULL; + JK_TRACE_EXIT(l); return JK_TRUE; } -jk_log(l, JK_LOG_ERROR, In jk_endpoint_t::done: NULL Parameters\n); + JK_LOG_NULL_PARAMS(l); return JK_FALSE; } @@ -386,7 +387,7 @@ jk_map_t *props, jk_worker_env_t *we, jk_logger_t *l) { -jk_log(l, JK_LOG_DEBUG, Into jk_worker_t::validate\n); + JK_TRACE_ENTER(l); if (pThis pThis-worker_private) { lb_worker_t *p = pThis-worker_private; @@ -476,13 +477,13 @@ local_worker_only: %s\n, (p-local_worker_only ? true : false)); p-num_of_workers = num_of_workers; + JK_TRACE_EXIT(l); return JK_TRUE; } } } -jk_log(l, JK_LOG_ERROR, In jk_worker_t::validate: NULL Parameters\n); - + JK_LOG_NULL_PARAMS(l); return JK_FALSE; }
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2004/11/08 05:39:27 Modified:jk/native/common jk_connect.c Log: Use socket timeout, and use read/write on unix platforms. Use macros for WIN32/Netware socket errors. Revision ChangesPath 1.28 +204 -56 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.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- jk_connect.c 8 Oct 2004 07:50:39 - 1.27 +++ jk_connect.c 8 Nov 2004 13:39:27 - 1.28 @@ -21,6 +21,7 @@ /** * @package jk_connect * @author Gal Shachor [EMAIL PROTECTED] + * @author Mladen Turk [EMAIL PROTECTED] * @version $Revision$ */ @@ -38,6 +39,14 @@ typedef u_long in_addr_t; #endif +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) +#define JK_IS_SOCKET_ERROR(x) ((x) == SOCKET_ERROR) +#define JK_GET_SOCKET_ERRNO() errno = WSAGetLastError() - WSABASEERR +#else +#define JK_IS_SOCKET_ERROR(x) ((x) == -1) +#define JK_GET_SOCKET_ERRNO() ((void)0) +#endif /* WIN32 */ + /** resolve the host IP */ @@ -125,8 +134,8 @@ /** connect to Tomcat */ -int jk_open_socket(struct sockaddr_in *addr, - int ndelay, int keepalive, jk_logger_t *l) +int jk_open_socket(struct sockaddr_in *addr, int ndelay, + int keepalive, int timeout, jk_logger_t *l) { char buf[32]; int sock; @@ -134,8 +143,23 @@ jk_log(l, JK_LOG_DEBUG, Into jk_open_socket\n); sock = socket(AF_INET, SOCK_STREAM, 0); -if (sock -1) { -int ret; +if (sock = 0) { +int ret, len; +if (timeout != -1) { +ret = jk_socket_timeout_set(sock, -1, timeout); +if (ret) { +jk_close_socket(sock); +jk_log(l, JK_LOG_INFO, + jk_open_socket, timeout_set failed errno = %d\n, + ret); +return -1; +} +jk_log(l, JK_LOG_DEBUG, +jk_open_socket, set timeout to %d with status %d\n, +timeout, ret); + +} + /* Tries to connect to Tomcat (continues trying while error is EINTR) */ do { jk_log(l, JK_LOG_DEBUG, @@ -149,7 +173,7 @@ #endif ret = connect(sock, (struct sockaddr *)addr, - sizeof(struct sockaddr_in)); + sizeof(struct sockaddr_in)); #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if (SOCKET_ERROR == ret) { errno = WSAGetLastError() - WSABASEERR; @@ -160,41 +184,57 @@ } while (-1 == ret EINTR == errno); /* Check if we connected */ -if (0 == ret) { +if (ret == -1) { +jk_log(l, JK_LOG_INFO, + jk_open_socket, connect() failed errno = %d\n, errno); +jk_close_socket(sock); +return -1; +} +if (ndelay) { +int set = 1; +jk_log(l, JK_LOG_DEBUG, + jk_open_socket, set TCP_NODELAY to on\n); +setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)set, + sizeof(set)); +} +if (keepalive) { int keep = 1; -if (ndelay) { -int set = 1; - -jk_log(l, JK_LOG_DEBUG, - jk_open_socket, set TCP_NODELAY to on\n); -setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)set, - sizeof(set)); -} +jk_log(l, JK_LOG_DEBUG, +jk_open_socket, set SO_KEEPALIVE to on\n); +setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char *)keep, +sizeof(keep)); +} +len = 8*1024; /* Default AJP packet size */ -if (keepalive) { -jk_log(l, JK_LOG_DEBUG, - jk_open_socket, set SO_KEEPALIVE to on\n); -setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char *)keep, - sizeof(keep)); -} +/* Set socket send buffer size */ +if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)len, + sizeof(len))) { +JK_GET_SOCKET_ERRNO(); +jk_log(l, JK_LOG_ERROR, + ERROR: jk_open_socket, failed setting sndbuf errno = %d\n, errno); +jk_close_socket(sock); +return -1; +} +/* Set socket receive buffer size */ +if (setsockopt(sock,
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/14 01:37:05 Modified:jk/native/common jk_connect.c Log: For now the sa_len is set only when using iSeries in Unix 98 mode... Revision ChangesPath 1.25 +2 -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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- jk_connect.c 13 Jul 2004 11:08:17 - 1.24 +++ jk_connect.c 14 Jul 2004 08:37:05 - 1.25 @@ -145,7 +145,7 @@ /* Need more infos for BSD 4.4 and Unix 98 defines, for now only iSeries when Unix98 is required at compil time */ -#if (_XOPEN_SOURCE = 520) +#if (_XOPEN_SOURCE = 520) defined(AS400) ((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in)); #endif ret = connect(sock, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/14 06:10:22 Modified:jk/native/common jk_connect.c Log: Et une boulette, une. Fait pas bon bosser le 14 Juillet :) Revision ChangesPath 1.26 +2 -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.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- jk_connect.c 14 Jul 2004 08:37:05 - 1.25 +++ jk_connect.c 14 Jul 2004 13:10:22 - 1.26 @@ -146,7 +146,7 @@ /* Need more infos for BSD 4.4 and Unix 98 defines, for now only iSeries when Unix98 is required at compil time */ #if (_XOPEN_SOURCE = 520) defined(AS400) -((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in)); +((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in); #endif ret = connect(sock, (struct sockaddr *)addr, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/12 23:50:57 Modified:jk/native/common jk_connect.c Log: Ensure the sockaddr_in is correctly initialized Revision ChangesPath 1.21 +3 -1 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.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- jk_connect.c 16 Mar 2004 11:12:59 - 1.20 +++ jk_connect.c 13 Jul 2004 06:50:57 - 1.21 @@ -47,6 +47,8 @@ { int x; +memset(rc, 0, sizeof(sockaddr_in)); + /* TODO: Should be updated for IPV6 support. */ /* for now use the correct type, in_addr_t */ /* except on NetWare since the MetroWerks compiler is so strict */ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/12 23:54:28 Modified:jk/native/common jk_connect.c Log: Oups Revision ChangesPath 1.22 +2 -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.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- jk_connect.c 13 Jul 2004 06:50:57 - 1.21 +++ jk_connect.c 13 Jul 2004 06:54:28 - 1.22 @@ -47,7 +47,7 @@ { int x; -memset(rc, 0, sizeof(sockaddr_in)); +memset(rc, 0, sizeof(struct sockaddr_in)); /* TODO: Should be updated for IPV6 support. */ /* for now use the correct type, in_addr_t */ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/13 00:32:58 Modified:jk/native/common jk_connect.c Log: iSeries didn't like memset before var definitions so... Revision ChangesPath 1.23 +3 -3 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- jk_connect.c 13 Jul 2004 06:54:28 - 1.22 +++ jk_connect.c 13 Jul 2004 07:32:58 - 1.23 @@ -47,8 +47,6 @@ { int x; -memset(rc, 0, sizeof(struct sockaddr_in)); - /* TODO: Should be updated for IPV6 support. */ /* for now use the correct type, in_addr_t */ /* except on NetWare since the MetroWerks compiler is so strict */ @@ -57,6 +55,8 @@ #else in_addr_t laddr; #endif + +memset(rc, 0, sizeof(struct sockaddr_in)); rc-sin_port = htons((short)port); rc-sin_family = AF_INET; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/07/13 04:08:17 Modified:jk/native/common jk_connect.c Log: Make sure iSeries won't complain about invalid sa_len. Should add BSD 4.4/Unix98 defines here also Revision ChangesPath 1.24 +6 -1 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.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- jk_connect.c 13 Jul 2004 07:32:58 - 1.23 +++ jk_connect.c 13 Jul 2004 11:08:17 - 1.24 @@ -143,6 +143,11 @@ jk_log(l, JK_LOG_DEBUG, jk_open_socket, try to connect socket = %d to %s\n, sock, jk_dump_hinfo(addr, buf)); +/* Need more infos for BSD 4.4 and Unix 98 defines, for now only + iSeries when Unix98 is required at compil time */ +#if (_XOPEN_SOURCE = 520) +((struct sockaddr *)addr)-sa_len = sizeof(struct sockaddr_in)); +#endif ret = connect(sock, (struct sockaddr *)addr, sizeof(struct sockaddr_in)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/03/16 00:59:05 Modified:jk/native/common jk_connect.c Log: Avoid problems with netware boxes Revision ChangesPath 1.19 +3 -3 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- jk_connect.c 1 Mar 2004 13:37:38 - 1.18 +++ jk_connect.c 16 Mar 2004 08:59:05 - 1.19 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - in_addr_t laddr = htonl(saddr-sin_addr.s_addr); - in_port_t lport = htons(saddr-sin_port); + unsigned long laddr = htonl(saddr-sin_addr.s_addr); + unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.orig Mon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - in_addr_t laddr = htonl(saddr-sin_addr.s_addr); - in_port_t lport = htons(saddr-sin_port); + unsigned long laddr = htonl(saddr-sin_addr.s_addr); + unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. From my Linux manpage we shoulld use uint32_t and uint16_t for htonl and htons. What about Netware ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Henri Gomez wrote: Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.origMon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { -in_addr_t laddr = htonl(saddr-sin_addr.s_addr); -in_port_t lport = htons(saddr-sin_port); +unsigned long laddr = htonl(saddr-sin_addr.s_addr); +unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. From my Linux manpage we shoulld use uint32_t and uint16_t for htonl and htons. What about Netware ? For now I'm usin unsigned long and unsigned short - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
I sent email to [EMAIL PROTECTED] Why I still kept receiving mails from Tomcat Developers List [EMAIL PROTECTED]? Henri Gomez [EMAIL PROTECTED] 03/16/2004 03:58 AM Please respond to Tomcat Developers List To: Tomcat Developers List [EMAIL PROTECTED] cc: Subject:Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.orig Mon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - in_addr_t laddr = htonl(saddr-sin_addr.s_addr); - in_port_t lport = htons(saddr-sin_port); + unsigned long laddr = htonl(saddr-sin_addr.s_addr); + unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. From my Linux manpage we shoulld use uint32_t and uint16_t for htonl and htons. What about Netware ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Henri Gomez wrote: Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.origMon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { -in_addr_t laddr = htonl(saddr-sin_addr.s_addr); -in_port_t lport = htons(saddr-sin_port); +unsigned long laddr = htonl(saddr-sin_addr.s_addr); +unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. From my Linux manpage we shoulld use uint32_t and uint16_t for htonl and htons. Use that should prevent compilers beeing unhappy: +++ unsigned long laddr = (unsigned long) htonl(saddr-sin_addr.s_addr); unsigned short lport = (unsigned short) htons(saddr-sin_port); +++ What about Netware ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] signature.asc Description: OpenPGP digital signature
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2004/03/16 03:12:59 Modified:jk/native/common jk_connect.c Log: Make most compilers happy (typecast power) Revision ChangesPath 1.20 +3 -3 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- jk_connect.c 16 Mar 2004 08:59:05 - 1.19 +++ jk_connect.c 16 Mar 2004 11:12:59 - 1.20 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - unsigned long laddr = htonl(saddr-sin_addr.s_addr); - unsigned short lport = htons(saddr-sin_port); + unsigned long laddr = (unsigned long)htonl(saddr-sin_addr.s_addr); + unsigned short lport = (unsigned short)htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
jean-frederic clere wrote: Henri Gomez wrote: Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.origMon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { -in_addr_t laddr = htonl(saddr-sin_addr.s_addr); -in_port_t lport = htons(saddr-sin_port); +unsigned long laddr = htonl(saddr-sin_addr.s_addr); +unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. From my Linux manpage we shoulld use uint32_t and uint16_t for htonl and htons. Use that should prevent compilers beeing unhappy: +++ unsigned long laddr = (unsigned long) htonl(saddr-sin_addr.s_addr); unsigned short lport = (unsigned short) htons(saddr-sin_port); +++ Done - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.orig Mon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - in_addr_t laddr = htonl(saddr-sin_addr.s_addr); - in_port_t lport = htons(saddr-sin_port); + unsigned long laddr = htonl(saddr-sin_addr.s_addr); + unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Guenter Knauf wrote: Hi Henri, [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.orig Mon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { - in_addr_t laddr = htonl(saddr-sin_addr.s_addr); - in_port_t lport = htons(saddr-sin_port); + unsigned long laddr = htonl(saddr-sin_addr.s_addr); + unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Yep. Guenter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] signature.asc Description: OpenPGP digital signature
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
Hi Henri, just tested that it breaks compilation on Win32 platform to -- my patch solved it. Guenter. [EMAIL PROTECTED] wrote: hgomez 2004/03/01 05:47:23 Modified:jk/native/common jk_ajp_common.c Log: More debug/trace infos on remote tomcats I added more infos on IP/PORT of remote tomcats in jk, since I've some reports that there is a problem for admins to determine which tomcat is down when they have many workers defined... I overcome the inet_ntoa by using a jk_dump_hinfo function which should works also in multi-threaded env. It should works on Unixes, but I'd like to have reports from Win32, Netware and others exotics OS users... the change of --- jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/02/24 08:45:48 1.17 +++ jakarta-tomcat-connectors/jk/native/common/jk_connect.c 2004/03/01 13:37:38 1.18 breaks all targets on NetWare: netscape, apache-1.3 and apache-2; the problem is that in_addr_t and in_port_t are not defined. Futhermore I consider in_addr_t as a dangerous var, google a bit and you will see that some OSes define it as unsigned long (which is what we need here) while others define it to a struct in_addr. NetWare also defines it to the in_addr struct so that its useless here - and even more ugly it would be if I had to include netinet/in.h for other reasons, then I would have to undef at least in_addr_t. So we should avoid these typedefs at all, and simply use ulong and ushort. --- jk_connect.c.origMon Mar 15 16:04:08 2004 +++ jk_connect.c Mon Mar 15 18:16:28 2004 @@ -288,8 +288,8 @@ */ char * jk_dump_hinfo(struct sockaddr_in *saddr, char * buf) { -in_addr_t laddr = htonl(saddr-sin_addr.s_addr); -in_port_t lport = htons(saddr-sin_port); +unsigned long laddr = htonl(saddr-sin_addr.s_addr); +unsigned short lport = htons(saddr-sin_port); sprintf(buf, %d.%d.%d.%d:%d, (int)(laddr 24), (int)((laddr 16) 0xff), (int)((laddr 8) 0xff), (int)(laddr 0xff), (int)lport); I've not tested this yet, but at least I can now compile again. In addtion our older clib has a strange behavior with these functions, so there's certainly another additional patch needed for apache-1.3 and netscape; apache-2 should work with the above. btw: we should really take care of tabs and avoid them - as outlined in the ASF developer docs. Currently there are a couple of files which contain tabs, they should be removed IMO. Guenter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mmanders2004/01/05 14:37:48 Modified:jk/native/common jk_connect.c Log: Added check for AF_INET (IPV4) type address from APR (when used). Revision ChangesPath 1.16 +14 -28jakarta-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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- jk_connect.c 5 Nov 2003 09:15:39 - 1.15 +++ jk_connect.c 5 Jan 2004 22:37:48 - 1.16 @@ -66,35 +66,9 @@ */ -#if defined(NETWARE) defined(__NOVELL_LIBC__) -/* Since we want to use WinSock functionality here, don't allow the - * non-winsock headers - */ -#define __sys_types_h__ -#define __sys_socket_h__ -#define __netdb_h__ -#define __netinet_in_h__ -#define __arpa_inet_h__ -#define __sys_timeval_h__ -#endif - #include jk_connect.h #include jk_util.h -#if defined(NETWARE) defined(__NOVELL_LIBC__) -/* Now remove the defines so that including the WinSock headers won't cause - * complaining - */ -#undef __sys_types_h__ -#undef __sys_socket_h__ -#undef __netdb_h__ -#undef __netinet_in_h__ -#undef __arpa_inet_h__ -#undef __sys_timeval_h__ - -#include novsock2.h -#endif - #ifdef HAVE_APR #include apr_network_io.h #include apr_errno.h @@ -138,7 +112,7 @@ #ifdef HAVE_APR apr_pool_t *context; -apr_sockaddr_t *remote_sa; +apr_sockaddr_t *remote_sa, *temp_sa; char *remote_ipaddr; /* May be we could avoid to recreate it each time ? */ @@ -147,6 +121,18 @@ if (apr_sockaddr_info_get(remote_sa, host, APR_UNSPEC, (apr_port_t)port, 0, context) != APR_SUCCESS) +return JK_FALSE; + +/* Since we are only handling AF_INET (IPV4) address (in_addr_t) */ +/* make sure we find one of those. */ +temp_sa = remote_sa; +while ((NULL != temp_sa) (AF_INET != temp_sa-family)) +temp_sa = temp_sa-next; + +/* if temp_sa is set, we have a valid address otherwise, just return */ +if (NULL != temp_sa) +remote_sa = temp_sa; +else return JK_FALSE; apr_sockaddr_ip_get(remote_ipaddr, remote_sa); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mmanders2003/09/05 08:19:29 Modified:jk/native/common jk_connect.c Log: Added special case for NetWare since the MetroWerks compiler is so strict on types. Revision ChangesPath 1.14 +6 -1 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- jk_connect.c 30 Aug 2003 03:11:19 - 1.13 +++ jk_connect.c 5 Sep 2003 15:19:29 - 1.14 @@ -116,7 +116,12 @@ /* TODO: Should be updated for IPV6 support. */ /* for now use the correct type, in_addr_t */ +/* except on NetWare since the MetroWerks compiler is so strict */ +#if defined(NETWARE) +u_long laddr; +#else in_addr_t laddr; +#endif rc-sin_port = htons((short)port); rc-sin_family = AF_INET; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
billbarker2003/08/29 20:11:19 Modified:jk/native/common jk_connect.c Log: Define in_addr_t for Windows platform. Submitted by: Marc Saegesser Revision ChangesPath 1.13 +6 -1 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- jk_connect.c 29 Aug 2003 13:07:52 - 1.12 +++ jk_connect.c 30 Aug 2003 03:11:19 - 1.13 @@ -101,6 +101,11 @@ #include apr_general.h #endif +#if defined(WIN32) +typedef u_long in_addr_t; +#endif + + /** resolve the host IP */ int jk_resolve(char *host, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2003/08/29 06:07:52 Modified:jk/native/common jk_connect.c Log: No more special iSeries defines now that we define _XOPEN_SOURCE=520 in build script... ie: CRTCMOD MODULE(MOD_JK/JK_CONNECT) + SRCSTMF('/home/apache/jk/native/common/jk_connect.c') + DEFINE('AS400' 'HAVE_JNI' 'HAVE_APR' '_XOPEN_SOURCE=520' + 'USE_APACHE_MD5' '_REENTRANT') + TEXT('jk_connect.c') + OPTIMIZE(40) + SYSIFCOPT(*IFSIO) + LANGLVL(*ANSI) + TGTCCSID(*JOB) + OPTION(*LOGMSG) + TERASPACE(*YES *TSIFC) + STGMDL(*INHERIT) + INCDIR('/home/apache/jk/native/common' '/QIBM/ProdData/HTTPA/Include') Revision ChangesPath 1.12 +2 -7 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- jk_connect.c 26 Aug 2003 10:07:37 - 1.11 +++ jk_connect.c 29 Aug 2003 13:07:52 - 1.12 @@ -110,13 +110,8 @@ int x; /* TODO: Should be updated for IPV6 support. */ -/* for now use the correct type, in_addr_t (or u_long for OS400) */ - -#ifdef AS400 -u_long laddr; -#else +/* for now use the correct type, in_addr_t */ in_addr_t laddr; -#endif rc-sin_port = htons((short)port); rc-sin_family = AF_INET; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2003/08/26 03:07:37 Modified:jk/native2/common jk_channel_socket.c jk/native/common jk_connect.c Log: Make use of in_addr_t instead of u_long for all platforms but OS400. Should make jk build on OpenBSD/64 Revision ChangesPath 1.55 +6 -1 jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c Index: jk_channel_socket.c === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- jk_channel_socket.c 31 Jul 2003 14:49:32 - 1.54 +++ jk_channel_socket.c 26 Aug 2003 10:07:36 - 1.55 @@ -246,8 +246,13 @@ int x; /* TODO: Should be updated for IPV6 support. */ -/* for now use the correct type, in_addr_t */ +/* for now use the correct type, in_addr_t (or u_long for OS400) */ + +#ifdef AS400 +u_long laddr; +#else in_addr_t laddr; +#endif rc-sin_port = htons((short)port); rc-sin_family = AF_INET; 1.11 +7 -1 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- jk_connect.c 25 Jul 2003 14:58:22 - 1.10 +++ jk_connect.c 26 Aug 2003 10:07:37 - 1.11 @@ -110,7 +110,13 @@ int x; /* TODO: Should be updated for IPV6 support. */ +/* for now use the correct type, in_addr_t (or u_long for OS400) */ + +#ifdef AS400 u_long laddr; +#else + in_addr_t laddr; +#endif rc-sin_port = htons((short)port); rc-sin_family = AF_INET; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
hgomez 2003/07/25 07:58:22 Modified:jk/native/common jk_connect.c Log: Use u_long instead of in_addr_t which make unhappy some platforms like iSeries Revision ChangesPath 1.10 +2 -3 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- jk_connect.c 24 Jul 2003 08:17:10 - 1.9 +++ jk_connect.c 25 Jul 2003 14:58:22 - 1.10 @@ -110,8 +110,7 @@ int x; /* TODO: Should be updated for IPV6 support. */ -/* for now use the correct type, in_addr_t */ -in_addr_t laddr; +u_long laddr; rc-sin_port = htons((short)port); rc-sin_family = AF_INET; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
[EMAIL PROTECTED] a écrit : hgomez 2003/07/25 07:58:22 Modified:jk/native/common jk_connect.c Log: Use u_long instead of in_addr_t which make unhappy some platforms like iSeries Revision ChangesPath 1.10 +2 -3 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- jk_connect.c 24 Jul 2003 08:17:10 - 1.9 +++ jk_connect.c 25 Jul 2003 14:58:22 - 1.10 @@ -110,8 +110,7 @@ int x; /* TODO: Should be updated for IPV6 support. */ -/* for now use the correct type, in_addr_t */ -in_addr_t laddr; +u_long laddr; Revert back to previous type declaration (make iSeries more happy). BTW, we may have to rework it soon since we're now IPV6 compatible - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
costin 2003/02/17 08:59:47 Modified:jk/native/common jk_connect.c Log: Return more usefull information from recv, to help debug. Revision ChangesPath 1.8 +7 -5 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- jk_connect.c 6 Dec 2002 18:52:50 - 1.7 +++ jk_connect.c 17 Feb 2003 16:59:47 - 1.8 @@ -263,11 +263,11 @@ return sent; } -/** receive len bytes. +/** receive len bytes. Used in ajp_common. * @param sd opened socket. * @param b buffer to store the data. * @param len length to receive. - * @return-1: receive failed or connection closed. + * @return0: receive failed or connection closed. *0: length of the received data. */ int jk_tcp_socket_recvfull(int sd, @@ -283,6 +283,7 @@ 0); if(-1 == this_time) { #if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) +/* I assume SOCKET_ERROR == -1 */ if(SOCKET_ERROR == this_time) { errno = WSAGetLastError() - WSABASEERR; } @@ -290,8 +291,9 @@ if(EAGAIN == errno) { continue; -} -return -1; +} +/** Pass the errno to the caller */ +return (errno0) ? -errno : errno; } if(0 == this_time) { return -1; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mmanders2002/12/06 10:52:50 Modified:jk/native/common jk_connect.c Log: Modified code to go through a WinSock code path on NetWare if building for Apache 2. Revision ChangesPath 1.7 +31 -5 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- jk_connect.c 30 Oct 2002 22:12:20 - 1.6 +++ jk_connect.c 6 Dec 2002 18:52:50 - 1.7 @@ -66,9 +66,35 @@ */ +#if defined(NETWARE) defined(__NOVELL_LIBC__) +/* Since we want to use WinSock functionality here, don't allow the + * non-winsock headers + */ +#define __sys_types_h__ +#define __sys_socket_h__ +#define __netdb_h__ +#define __netinet_in_h__ +#define __arpa_inet_h__ +#define __sys_timeval_h__ +#endif + #include jk_connect.h #include jk_util.h +#if defined(NETWARE) defined(__NOVELL_LIBC__) +/* Now remove the defines so that including the WinSock headers won't cause + * complaining + */ +#undef __sys_types_h__ +#undef __sys_socket_h__ +#undef __netdb_h__ +#undef __netinet_in_h__ +#undef __arpa_inet_h__ +#undef __sys_timeval_h__ + +#include novsock2.h +#endif + /** resolve the host IP */ int jk_resolve(char *host, @@ -140,7 +166,7 @@ ret = connect(sock, (struct sockaddr *)addr, sizeof(struct sockaddr_in)); -#ifdef WIN32 +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if(SOCKET_ERROR == ret) { errno = WSAGetLastError() - WSABASEERR; } @@ -177,7 +203,7 @@ jk_log(l, JK_LOG_INFO, jk_open_socket, connect() failed errno = %d\n, errno); jk_close_socket(sock); } else { -#ifdef WIN32 +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) errno = WSAGetLastError() - WSABASEERR; #endif /* WIN32 */ jk_log(l, JK_LOG_ERROR, jk_open_socket, socket() failed errno = %d\n, errno); @@ -190,7 +216,7 @@ int jk_close_socket(int s) { -#ifdef WIN32 +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if(INVALID_SOCKET != s) { return closesocket(s) ? -1 : 0; } @@ -256,7 +282,7 @@ len - rdlen, 0); if(-1 == this_time) { -#ifdef WIN32 +#if defined(WIN32) || (defined(NETWARE) defined(__NOVELL_LIBC__)) if(SOCKET_ERROR == this_time) { errno = WSAGetLastError() - WSABASEERR; } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
mturk 2002/06/25 00:07:14 Modified:jk/native/common jk_connect.c Log: Introduced socket and cache timeout. By Jan Singer, Henri Gomez and Mladen Turk. Revision ChangesPath 1.4 +29 -18jakarta-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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- jk_connect.c 4 Jul 2001 16:59:38 - 1.3 +++ jk_connect.c 25 Jun 2002 07:07:14 - 1.4 @@ -60,7 +60,7 @@ * Based on:Various Jserv files */ /** - * @package jk_connect + * @package jk_connect * @author Gal Shachor [EMAIL PROTECTED] * @version $Revision$ */ @@ -109,6 +109,7 @@ int jk_open_socket(struct sockaddr_in *addr, int ndelay, + int keepalive, jk_logger_t *l) { int sock; @@ -134,6 +135,7 @@ /* Check if we connected */ if(0 == ret) { +int keep = 1; if(ndelay) { int set = 1; @@ -145,6 +147,15 @@ sizeof(set)); } +if (keepalive) { +jk_log(l, JK_LOG_DEBUG, jk_open_socket, set SO_KEEPALIVE to on\n); +setsockopt(sock, + SOL_SOCKET, + SO_KEEPALIVE, + (char *)keep, + sizeof(keep)); +} + jk_log(l, JK_LOG_DEBUG, jk_open_socket, return, sd = %d\n, sock); return sock; } @@ -198,14 +209,14 @@ (char *)b + sent , len - sent, 0); - - if(0 == this_time) { - return -2; - } - if(this_time 0) { - return -3; - } - sent += this_time; + +if(0 == this_time) { +return -2; +} +if(this_time 0) { +return -3; +} +sent += this_time; } return sent; @@ -225,26 +236,26 @@ int rdlen = 0; while(rdlen len) { - int this_time = recv(sd, +int this_time = recv(sd, (char *)b + rdlen, len - rdlen, - 0); - if(-1 == this_time) { + 0); +if(-1 == this_time) { #ifdef WIN32 if(SOCKET_ERROR == this_time) { errno = WSAGetLastError() - WSABASEERR; } #endif /* WIN32 */ - if(EAGAIN == errno) { +if(EAGAIN == errno) { continue; - } - return -1; - } +} +return -1; +} if(0 == this_time) { return -1; } - rdlen += this_time; +rdlen += this_time; } return rdlen; -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.c
jfclere 01/07/04 09:59:39 Modified:jk/native Makefile.am jk/native/common jk_connect.c Log: Add logic and first documentation for scandoc. Revision ChangesPath 1.2 +4 -0 jakarta-tomcat-connectors/jk/native/Makefile.am Index: Makefile.am === RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Makefile.am 2001/06/05 10:27:47 1.1 +++ Makefile.am 2001/07/04 16:59:36 1.2 @@ -15,3 +15,7 @@ (cd $$i $(MAKE) $$target) || exit 1; \ fi; \ done; + +apidocs: common/*.h + ../../scandoc/scandoc.pl -i ../../scandoc/template.pl -p \ + ./docs/api/ -dproject=mod_jk Library common/*.h common/*.c 1.3 +31 -6 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_connect.c 2001/06/18 14:15:34 1.2 +++ jk_connect.c 2001/07/04 16:59:38 1.3 @@ -55,17 +55,22 @@ * * * = */ -/*** - * Description: Socket/Naming manipulation functions * - * Author: Gal Shachor [EMAIL PROTECTED] * - * Based on:Various Jserv files* - * Version: $Revision: 1.2 $ * - ***/ +/* + * Description: Socket/Naming manipulation functions + * Based on:Various Jserv files + */ +/** + * @package jk_connect + * @author Gal Shachor [EMAIL PROTECTED] + * @version $Revision: 1.3 $ + */ #include jk_connect.h #include jk_util.h +/** resolve the host IP */ + int jk_resolve(char *host, short port, struct sockaddr_in *rc) @@ -100,6 +105,7 @@ return JK_TRUE; } +/** connect to Tomcat */ int jk_open_socket(struct sockaddr_in *addr, int ndelay, @@ -154,6 +160,8 @@ return -1; } +/** close the socket */ + int jk_close_socket(int s) { #ifdef WIN32 @@ -169,6 +177,16 @@ return -1; } +/** send a long message + * @param sd opened socket. + * @param b buffer containing the data. + * @param len length to send. + * @return-2: send returned 0 ? what this that ? + *-3: send failed. + *0: total size send. + * @bug this fails on Unixes if len is too big for the underlying + * protocol. + */ int jk_tcp_socket_sendfull(int sd, const unsigned char *b, int len) @@ -193,6 +211,13 @@ return sent; } +/** receive len bytes. + * @param sd opened socket. + * @param b buffer to store the data. + * @param len length to receive. + * @return-1: receive failed or connection closed. + *0: length of the received data. + */ int jk_tcp_socket_recvfull(int sd, unsigned char *b, int len)