Author: rjung Date: Tue Dec 11 10:24:31 2007 New Revision: 603320 URL: http://svn.apache.org/viewvc?rev=603320&view=rev Log: Add logger to all jk_connect socket functions.
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c tomcat/connectors/trunk/jk/native/common/jk_connect.c tomcat/connectors/trunk/jk/native/common/jk_connect.h tomcat/connectors/trunk/jk/native/nt_service/jk_nt_service.c Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c?rev=603320&r1=603319&r2=603320&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c Tue Dec 11 10:24:31 2007 @@ -160,7 +160,7 @@ if (e && *e && (*e)->endpoint_private) { ajp12_endpoint_t *p = (*e)->endpoint_private; if (IS_VALID_SOCKET(p->sd)) { - jk_shutdown_socket(p->sd); + jk_shutdown_socket(p->sd, l); } free(p); *e = NULL; @@ -192,7 +192,7 @@ p->name, host, port); if (port > 1024 && host) { - if (jk_resolve(host, port, &p->worker_inet_addr)) { + if (jk_resolve(host, port, &p->worker_inet_addr, l)) { return JK_TRUE; } jk_log(l, JK_LOG_ERROR, Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=603320&r1=603319&r2=603320&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Tue Dec 11 10:24:31 2007 @@ -686,7 +686,7 @@ static void ajp_reset_endpoint(ajp_endpoint_t * ae, jk_logger_t *l) { if (IS_VALID_SOCKET(ae->sd) && !ae->reuse) { - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, "reset socket with sd = %u", ae->sd ); @@ -704,7 +704,7 @@ JK_TRACE_ENTER(l); if (IS_VALID_SOCKET(ae->sd)) { - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, "closed socket with sd = %d", ae->sd); @@ -744,7 +744,7 @@ JK_LEAVE_CS(&aw->cs, rc); /* Close previous socket */ if (IS_VALID_SOCKET(sock)) - jk_shutdown_socket(sock); + jk_shutdown_socket(sock, l); } } @@ -925,7 +925,7 @@ } if ((rc = jk_tcp_socket_sendfull(ae->sd, msg->buf, - msg->len)) > 0) { + msg->len, l)) > 0) { ae->endpoint.wr += (jk_uint64_t)rc; JK_TRACE_EXIT(l); ae->last_errno = 0; @@ -954,7 +954,7 @@ JK_TRACE_ENTER(l); - rc = jk_tcp_socket_recvfull(ae->sd, head, AJP_HEADER_LEN); + rc = jk_tcp_socket_recvfull(ae->sd, head, AJP_HEADER_LEN, l); if (rc < 0) { ae->last_errno = errno; @@ -1030,7 +1030,7 @@ msg->len = msglen; msg->pos = 0; - rc = jk_tcp_socket_recvfull(ae->sd, msg->buf, msglen); + rc = jk_tcp_socket_recvfull(ae->sd, msg->buf, msglen, l); if (rc < 0) { ae->last_errno = errno; if (rc == JK_SOCKET_EOF) { @@ -1210,11 +1210,11 @@ while (IS_VALID_SOCKET(ae->sd)) { int rc = 0; err = 0; - if (!jk_is_socket_connected(ae->sd)) { + if (!jk_is_socket_connected(ae->sd, l)) { jk_log(l, JK_LOG_DEBUG, "(%s) socket %d is not connected any more (errno=%d)", ae->worker->name, ae->sd, errno); - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; err = 1; } @@ -1261,7 +1261,7 @@ jk_log(l, JK_LOG_ERROR, "(%s) error sending request. Unrecoverable operation", ae->worker->name); - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); return JK_FALSE; @@ -1310,7 +1310,7 @@ */ if (ajp_connection_tcp_send_message(ae, op->request, l) != JK_TRUE) { /* Close the socket if unable to send request */ - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; jk_log(l, JK_LOG_INFO, "(%s) error sending request on a fresh connection (errno=%d)", @@ -1321,7 +1321,7 @@ } else { /* Close the socket if unable to connect */ - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; jk_log(l, JK_LOG_INFO, "(%s) error connecting to the backend server (errno=%d)", @@ -1355,7 +1355,7 @@ if (postlen > AJP_HEADER_LEN) { if (ajp_connection_tcp_send_message(ae, op->post, l) != JK_TRUE) { /* Close the socket if unable to send request */ - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; jk_log(l, JK_LOG_ERROR, "(%s) failed resending request body (%d)", ae->worker->name, postlen); @@ -1375,7 +1375,7 @@ if (postlen > AJP_HEADER_LEN) { if (ajp_connection_tcp_send_message(ae, s->reco_buf, l) != JK_TRUE) { /* Close the socket if unable to send request */ - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; jk_log(l, JK_LOG_ERROR, "(%s) failed resending request body (lb mode) (%d)", @@ -1425,7 +1425,7 @@ s->content_read = (jk_uint64_t)len; if (ajp_connection_tcp_send_message(ae, op->post, l) != JK_TRUE) { /* Close the socket if unable to send request */ - jk_shutdown_socket(ae->sd); + jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; jk_log(l, JK_LOG_ERROR, "(%s) error sending request body", ae->worker->name); @@ -1810,7 +1810,7 @@ jk_log(l, JK_LOG_ERROR, "(%s) Tomcat is down or network problems", p->worker->name); - jk_shutdown_socket(p->sd); + jk_shutdown_socket(p->sd, l); p->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); return JK_FALSE; @@ -2218,7 +2218,7 @@ p->name, p->host, p->port); if (p->port > 1024) { - if (jk_resolve(p->host, p->port, &p->worker_inet_addr)) { + if (jk_resolve(p->host, p->port, &p->worker_inet_addr, l)) { JK_TRACE_EXIT(l); return JK_TRUE; } @@ -2499,7 +2499,7 @@ jk_log(l, JK_LOG_DEBUG, "Shutting down held socket %u in worker %s", sock, p->worker->name); - jk_shutdown_socket(sock); + jk_shutdown_socket(sock, l); } if (i >= 0) { if (JK_IS_DEBUG_LEVEL(l)) Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.c?rev=603320&r1=603319&r2=603320&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_connect.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_connect.c Tue Dec 11 10:24:31 2007 @@ -117,7 +117,7 @@ #if defined (WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) /* WIN32 implementation */ -static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout) +static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout, jk_logger_t *l) { int rc; if (timeout <= 0) @@ -167,7 +167,7 @@ #elif !defined(NETWARE) /* POSIX implementation */ -static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout) +static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout, jk_logger_t *l) { int rc = 0; @@ -216,7 +216,7 @@ } #else /* NETWARE implementation - blocking for now */ -static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout) +static int nb_connect(jk_sock_t sock, struct sockaddr *addr, int timeout, jk_logger_t *l) { return connect(sock, addr, sizeof(struct sockaddr_in)); } @@ -245,7 +245,7 @@ /** resolve the host IP */ -int jk_resolve(const char *host, int port, struct sockaddr_in *rc) +int jk_resolve(const char *host, int port, struct sockaddr_in *rc, jk_logger_t *l) { int x; struct in_addr laddr; @@ -349,7 +349,7 @@ sizeof(set))) { jk_log(l, JK_LOG_ERROR, "failed setting TCP_NODELAY (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -362,7 +362,7 @@ sizeof(set))) { jk_log(l, JK_LOG_ERROR, "failed setting SO_KEEPALIVE (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -379,7 +379,7 @@ JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, "failed setting SO_SNDBUF (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -390,7 +390,7 @@ JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, "failed setting SO_RCVBUF (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -432,7 +432,7 @@ JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, "failed setting SO_NOSIGPIPE (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -445,7 +445,7 @@ JK_GET_SOCKET_ERRNO(); jk_log(l, JK_LOG_ERROR, "failed setting SO_LINGER (errno=%d)", errno); - jk_close_socket(sock); + jk_close_socket(sock, l); JK_TRACE_EXIT(l); return JK_INVALID_SOCKET; } @@ -461,7 +461,7 @@ #if (_XOPEN_SOURCE >= 520) && defined(AS400) ((struct sockaddr *)addr)->sa_len = sizeof(struct sockaddr_in); #endif - ret = nb_connect(sock, (struct sockaddr *)addr, timeout); + ret = nb_connect(sock, (struct sockaddr *)addr, timeout, l); #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) if (ret == SOCKET_ERROR) { errno = WSAGetLastError() - WSABASEERR; @@ -473,7 +473,7 @@ jk_log(l, JK_LOG_INFO, "connect to %s failed (errno=%d)", jk_dump_hinfo(addr, buf), errno); - jk_close_socket(sock); + jk_close_socket(sock, l); sock = JK_INVALID_SOCKET; } else { @@ -487,7 +487,7 @@ /** close the socket */ -int jk_close_socket(jk_sock_t s) +int jk_close_socket(jk_sock_t s, jk_logger_t *l) { if (IS_VALID_SOCKET(s)) #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) @@ -510,7 +510,7 @@ #define SHUT_WR 0x01 #endif #endif -int jk_shutdown_socket(jk_sock_t s) +int jk_shutdown_socket(jk_sock_t s, jk_logger_t *l) { char dummy[512]; int rc = 0; @@ -525,7 +525,7 @@ * to the peer. */ if (shutdown(s, SHUT_WR)) { - return jk_close_socket(s); + return jk_close_socket(s, l); } /* Set up to wait for readable data on socket... */ @@ -562,7 +562,7 @@ } while (difftime(time(NULL), start) < MAX_SECS_TO_LINGER); - return jk_close_socket(s); + return jk_close_socket(s, l); } /** send a long message @@ -575,7 +575,7 @@ * @bug this fails on Unixes if len is too big for the underlying * protocol. */ -int jk_tcp_socket_sendfull(jk_sock_t sd, const unsigned char *b, int len) +int jk_tcp_socket_sendfull(jk_sock_t sd, const unsigned char *b, int len, jk_logger_t *l) { int sent = 0; int wr; @@ -609,7 +609,7 @@ * @return <0: receive failed or connection closed. * >0: length of the received data. */ -int jk_tcp_socket_recvfull(jk_sock_t sd, unsigned char *b, int len) +int jk_tcp_socket_recvfull(jk_sock_t sd, unsigned char *b, int len, jk_logger_t *l) { int rdlen = 0; int rd; @@ -653,7 +653,7 @@ return buf; } -int jk_is_socket_connected(jk_sock_t sock) +int jk_is_socket_connected(jk_sock_t sock, jk_logger_t *l) { fd_set fd; struct timeval tv; Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.h URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.h?rev=603320&r1=603319&r2=603320&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_connect.h (original) +++ tomcat/connectors/trunk/jk/native/common/jk_connect.h Tue Dec 11 10:24:31 2007 @@ -39,22 +39,22 @@ #define JK_SOCKET_EOF (-2) #define JK_SOCKET_ERROR (-3) -int jk_resolve(const char *host, int port, struct sockaddr_in *rc); +int jk_resolve(const char *host, int port, struct sockaddr_in *rc, jk_logger_t *l); jk_sock_t jk_open_socket(struct sockaddr_in *addr, int keepalive, int timeout, int sock_buf, jk_logger_t *l); -int jk_close_socket(jk_sock_t s); +int jk_close_socket(jk_sock_t s, jk_logger_t *l); -int jk_shutdown_socket(jk_sock_t s); +int jk_shutdown_socket(jk_sock_t s, jk_logger_t *l); -int jk_tcp_socket_sendfull(jk_sock_t sd, const unsigned char *b, int len); +int jk_tcp_socket_sendfull(jk_sock_t sd, const unsigned char *b, int len, jk_logger_t *l); -int jk_tcp_socket_recvfull(jk_sock_t sd, unsigned char *b, int len); +int jk_tcp_socket_recvfull(jk_sock_t sd, unsigned char *b, int len, jk_logger_t *l); char *jk_dump_hinfo(struct sockaddr_in *saddr, char *buf); -int jk_is_socket_connected(jk_sock_t sd); +int jk_is_socket_connected(jk_sock_t sd, jk_logger_t *l); /*** Modified: tomcat/connectors/trunk/jk/native/nt_service/jk_nt_service.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/nt_service/jk_nt_service.c?rev=603320&r1=603319&r2=603320&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/nt_service/jk_nt_service.c (original) +++ tomcat/connectors/trunk/jk/native/nt_service/jk_nt_service.c Tue Dec 11 10:24:31 2007 @@ -871,7 +871,7 @@ return; } - if(jk_resolve("localhost", port, &in)) { + if(jk_resolve("localhost", port, &in, NULL)) { int sd = jk_open_socket(&in, JK_TRUE, 0, -1, NULL); if(sd >0) { int rc = JK_FALSE; @@ -910,7 +910,8 @@ if(0 > jk_tcp_socket_sendfull(sd, msg->buf, - msg->len)) { + msg->len, + NULL)) { rc = JK_FALSE; } } @@ -921,7 +922,7 @@ rc = JK_TRUE; } } - jk_close_socket(sd); + jk_close_socket(sd, NULL); if(JK_TRUE == rc) { if(WAIT_OBJECT_0 == WaitForSingleObject(hTomcat, 30*1000)) { return; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]