You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by hg...@apache.org on 2004/03/01 14:37:38 UTC

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_connect.h jk_ajp_common.c jk_connect.c

hgomez      2004/03/01 05:37:38

  Modified:    jk/native/common jk_connect.h jk_ajp_common.c jk_connect.c
  Log:
  Dump informations about remote tomcat in form : A.B.C.D:PORT
  
  Revision  Changes    Path
  1.7       +4 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_connect.h	24 Feb 2004 08:45:47 -0000	1.6
  +++ jk_connect.h	1 Mar 2004 13:37:38 -0000	1.7
  @@ -53,6 +53,9 @@
                              unsigned char *b, 
                              int len);
   
  +char * jk_dump_hinfo(struct sockaddr_in *saddr, 
  +                     char * buf);
  +
   #ifdef __cplusplus
   }
   #endif /* __cplusplus */
  
  
  
  1.54      +9 -7      jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c
  
  Index: jk_ajp_common.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- jk_ajp_common.c	1 Mar 2004 11:21:03 -0000	1.53
  +++ jk_ajp_common.c	1 Mar 2004 13:37:38 -0000	1.54
  @@ -691,6 +691,7 @@
   int ajp_connect_to_endpoint(ajp_endpoint_t *ae,
                               jk_logger_t    *l)
   {
  +	char buf[32];
       unsigned attempt;
   
       for(attempt = 0; attempt < ae->worker->connect_retry_attempts; attempt++) {
  @@ -699,8 +700,8 @@
           if(ae->sd >= 0) {
               jk_log(l, JK_LOG_DEBUG,
                      "In jk_endpoint_t::ajp_connect_to_endpoint, "
  -                   "connected sd = %d, port = %d\n",
  -                   ae->sd, (int)ae->worker->worker_inet_addr.sin_port);
  +                   "connected sd = %d to %s\n",
  +                   ae->sd, jk_dump_hinfo(&ae->worker->worker_inet_addr, buf));
   
                /* set last_access */
                ae->last_access = time(NULL);
  @@ -718,8 +719,8 @@
   
       jk_log(l, JK_LOG_INFO,
              "Error connecting to tomcat. Tomcat is probably not started or is "
  -           "listening on the wrong port (%d). Failed errno = %d\n",
  -           (int)ae->worker->worker_inet_addr.sin_port, errno);
  +           "listening on the wrong host/port (%s). Failed errno = %d\n",
  +           jk_dump_hinfo(&ae->worker->worker_inet_addr, buf), errno);
       return JK_FALSE;
   }
   
  @@ -766,6 +767,7 @@
       int           rc;
       int           msglen;
       unsigned int  header;
  +    char buf[32];
   
       if ((ae->proto != AJP13_PROTO) && (ae->proto != AJP14_PROTO)) {
           jk_log(l, JK_LOG_ERROR,
  @@ -780,8 +782,8 @@
       if(rc < 0) {
           jk_log(l, JK_LOG_ERROR,
                  "ERROR: can't receive the response message from tomcat, "
  -               "network problems or tomcat is down. err=%d\n",
  -               rc);
  +               "network problems or tomcat is down (%s), err=%d\n",
  +               jk_dump_hinfo(&ae->worker->worker_inet_addr, buf), rc);
           return JK_FALSE;
       }
   
  
  
  
  1.18      +21 -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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_connect.c	24 Feb 2004 08:45:48 -0000	1.17
  +++ jk_connect.c	1 Mar 2004 13:37:38 -0000	1.18
  @@ -128,6 +128,7 @@
                      int keepalive,
                      jk_logger_t *l)
   {
  +    char buf[32];   
       int sock;
   
       jk_log(l, JK_LOG_DEBUG, "Into jk_open_socket\n");
  @@ -135,9 +136,11 @@
       sock = socket(AF_INET, SOCK_STREAM, 0);
       if(sock > -1) {
           int ret;
  -        /* Tries to connect to JServ (continues trying while error is EINTR) */
  +        /* 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\n", sock);
  +            jk_log(l, JK_LOG_DEBUG, "jk_open_socket, try to connect socket = %d to %s\n", 
  +                   sock, jk_dump_hinfo(addr, buf));
  +                   
               ret = connect(sock,
                             (struct sockaddr *)addr,
                             sizeof(struct sockaddr_in));
  @@ -277,4 +280,19 @@
       }
   
       return rdlen;
  +}
  +
  +/**
  + * dump a sockaddr_in in A.B.C.D:P in ASCII buffer
  + *
  + */
  +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);
  +
  +	sprintf(buf, "%d.%d.%d.%d:%d", 
  +	        (int)(laddr >> 24), (int)((laddr >> 16) & 0xff), (int)((laddr >> 8) & 0xff), (int)(laddr & 0xff), (int)lport);
  +	        
  +	return buf;
   }
  
  
  

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