tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shac...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/native/jk jk_ajp13.c jk_ajp13.h jk_ajp13_worker.c jk_util.c
Date Fri, 16 Jun 2000 07:03:23 GMT
shachor     00/06/16 00:03:23

  Modified:    src/native/jk jk_ajp13.c jk_ajp13.h jk_ajp13_worker.c
                        jk_util.c
  Log:
  Logging improvements and bof bug fix
  
  Revision  Changes    Path
  1.4       +35 -1     jakarta-tomcat/src/native/jk/jk_ajp13.c
  
  Index: jk_ajp13.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_ajp13.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_ajp13.c	2000/05/29 12:53:24	1.3
  +++ jk_ajp13.c	2000/06/16 07:03:21	1.4
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Experimental bi-directionl protocol handler.               *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.3 $                                           *
  + * Version:     $Revision: 1.4 $                                           *
    ***************************************************************************/
   
   
  @@ -510,9 +510,17 @@
   
       d->msg = jk_b_get_string(msg);
   
  +    jk_log(l, JK_LOG_DEBUG, 
  +           "ajp13_unmarshal_response: status = %d\n",
  +           d->status);
  +
       d->num_headers = jk_b_get_int(msg);
       d->header_names = d->header_values = NULL;
   
  +    jk_log(l, JK_LOG_DEBUG, 
  +           "ajp13_unmarshal_response: Number of headers is = %d\n",
  +           d->num_headers);
  +
       if(d->num_headers) {
           d->header_names = jk_pool_alloc(p, sizeof(char *) * d->num_headers);
           d->header_values = jk_pool_alloc(p, sizeof(char *) * d->num_headers);
  @@ -550,8 +558,34 @@
   
                       return JK_FALSE;
                   }
  +
  +                jk_log(l, JK_LOG_DEBUG, 
  +                    "ajp13_unmarshal_response: Header[%d] [%s] = [%s]\n",
  +                    i,
  +                    d->header_names[i],
  +                    d->header_values[i]);
               }
           }
  +    }
  +
  +    return JK_TRUE;
  +}
  +
  +int ajp13_marshal_shutdown_into_msgb(jk_msg_buf_t *msg,
  +                                     jk_pool_t *p,
  +                                     jk_logger_t *l)
  +{
  +    jk_log(l, JK_LOG_DEBUG, 
  +           "Into ajp13_marshal_shutdown_into_msgb\n");
  +    
  +    /* To be on the safe side */
  +    jk_b_reset(msg);
  +
  +    /*
  +     * Just a single byte with s/d command.
  +     */
  +    if(0 != jk_b_append_byte(msg, JK_AJP13_SHUTDOWN)) {
  +        return JK_FALSE;
       }
   
       return JK_TRUE;
  
  
  
  1.3       +12 -1     jakarta-tomcat/src/native/jk/jk_ajp13.h
  
  Index: jk_ajp13.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_ajp13.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_ajp13.h	2000/05/25 14:17:47	1.2
  +++ jk_ajp13.h	2000/06/16 07:03:21	1.3
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Experimental bi-directionl protocol handler.               *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   #ifndef JK_AJP13_H
   #define JK_AJP13_H
  @@ -107,6 +107,11 @@
    */
   #define JK_AJP13_GET_BODY_CHUNK     (unsigned char)6
   
  +/*
  + * Asks the container to shutdown
  + */
  +#define JK_AJP13_SHUTDOWN           (unsigned char)7
  +
   struct jk_res_data {
       int         status;
       const char *msg;
  @@ -124,6 +129,12 @@
                                jk_res_data_t *d,
                                jk_pool_t *p,
                                jk_logger_t *l);
  +
  +
  +int ajp13_marshal_shutdown_into_msgb(jk_msg_buf_t *msg,
  +                                     jk_pool_t *p,
  +                                     jk_logger_t *l);
  +
   #ifdef __cplusplus
   }
   #endif /* __cplusplus */
  
  
  
  1.3       +22 -3     jakarta-tomcat/src/native/jk/jk_ajp13_worker.c
  
  Index: jk_ajp13_worker.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_ajp13_worker.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_ajp13_worker.c	2000/05/25 14:17:47	1.2
  +++ jk_ajp13_worker.c	2000/06/16 07:03:21	1.3
  @@ -57,7 +57,7 @@
    * Description: Experimental bi-directionl protocol.                       *
    * Author:      Costin <costin@costin.dnt.ro>                              *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -200,10 +200,14 @@
       rc = jk_tcp_socket_recvfull(ep->sd, head, 4);
   
       if(rc < 0) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "connection_tcp_get_message: Error - jk_tcp_socket_recvfull failed\n");
           return JK_FALSE;
       }
       
       if((head[0] != 'A') || (head[1] != 'B' )) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "connection_tcp_get_message: Error - Wrong message format\n");
   	    return JK_FALSE;
       }
   
  @@ -211,6 +215,8 @@
       msglen += (head[3] & 0xFF);
   
       if(msglen > jk_b_get_size(msg)) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "connection_tcp_get_message: Error - Wrong message size\n");
   	    return JK_FALSE;
       }
       
  @@ -219,6 +225,8 @@
   
       rc = jk_tcp_socket_recvfull(ep->sd, jk_b_get_buff(msg), msglen);
       if(rc < 0) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "connection_tcp_get_message: Error - jk_tcp_socket_recvfull failed\n");
           return JK_FALSE;
       }
           
  @@ -260,12 +268,16 @@
       read_buf += 2; /* leave some space for the read length */
   
       if(read_fully_from_server(r, read_buf, len) <= 0) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "read_into_msg_buff: Error - read_fully_from_server failed\n");
           return JK_FALSE;                        
       } 
       
       ep->left_bytes_to_send -= len;
   
       if(0 != jk_b_append_int(msg, (unsigned short)len)) {
  +        jk_log(l, JK_LOG_ERROR, 
  +               "read_into_msg_buff: Error - jk_b_append_int failed\n");
           return JK_FALSE;
       }
   
  @@ -289,6 +301,8 @@
                                                &res,
                                                &ep->pool,
                                                l)) {
  +                    jk_log(l, JK_LOG_ERROR, 
  +                           "Error ajp13_process_callback - ajp13_unmarshal_response failed\n");
                       return JK_AJP13_ERROR;
                   }
                   if(!r->start_response(r, 
  @@ -297,6 +311,8 @@
                                         (const char * const *)res.header_names,
                                         (const char * const *)res.header_values,
                                         res.num_headers)) {
  +                    jk_log(l, JK_LOG_ERROR, 
  +                           "Error ajp13_process_callback - start_response failed\n");
                       return JK_INTERNAL_ERROR;
                   }
               }
  @@ -306,6 +322,8 @@
               {
   	            unsigned len = (unsigned)jk_b_get_int(msg);
                   if(!r->write(r, jk_b_get_buff(msg) + jk_b_get_pos(msg), len)) {
  +                    jk_log(l, JK_LOG_ERROR, 
  +                           "Error ajp13_process_callback - write failed\n");
                       return JK_INTERNAL_ERROR;
                   }
               }
  @@ -326,6 +344,8 @@
                           return JK_AJP13_HAS_RESPONSE;
                       }                  
   
  +                    jk_log(l, JK_LOG_ERROR, 
  +                           "Error ajp13_process_callback - read_into_msg_buff failed\n");
                       return JK_INTERNAL_ERROR;
                   }
               }
  @@ -346,10 +366,9 @@
   	    break;
   
           default:
  -	        jk_b_dump(msg , "Invalid code");
   	        jk_log(l, 
                      JK_LOG_ERROR,
  -		           "Invalid code: %d\n", code);
  +		           "Error ajp13_process_callback - Invalid code: %d\n", code);
   	        return JK_AJP13_ERROR;
       }
       
  
  
  
  1.5       +16 -4     jakarta-tomcat/src/native/jk/jk_util.c
  
  Index: jk_util.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/jk/jk_util.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_util.c	2000/05/31 11:24:03	1.4
  +++ jk_util.c	2000/06/16 07:03:21	1.5
  @@ -56,7 +56,7 @@
   /***************************************************************************
    * Description: Utility functions (mainly configuration)                   *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
  - * Version:     $Revision: 1.4 $                                               *
  + * Version:     $Revision: 1.5 $                                               *
    ***************************************************************************/
   
   
  @@ -193,6 +193,7 @@
           char buf[HUGE_BUFFER_SIZE];
           char *f = (char *)(file + strlen(file) - 1);
           va_list args;
  +        int used = 0;
   
           while(f != file && '\\' != *f && '/' != *f) {
               f--;
  @@ -200,11 +201,22 @@
           if(f != file) {
               f++;
           }
  -        sprintf(buf, "[%s (%d)]: ", f, line);
  +                       
  +#ifdef WIN32
  +        used = _snprintf(buf, HUGE_BUFFER_SIZE, "[%s (%d)]: ", f, line);        
  +#else 
  +        used = snprintf(buf, HUGE_BUFFER_SIZE, "[%s (%d)]: ", f, line);        
  +#endif
  +        if(used < 0) {
  +            return 0; /* [V] not sure what to return... */
  +        }
       
           va_start(args, fmt);
  -
  -        rc = vsprintf(buf + strlen(buf), fmt, args);
  +#ifdef WIN32
  +        rc = _vsnprintf(buf + used, HUGE_BUFFER_SIZE - used, fmt, args);
  +#else 
  +        rc = vsnprintf(buf + used, HUGE_BUFFER_SIZE - used, fmt, args);
  +#endif
           va_end(args);
           l->log(l, level, buf);
       }
  
  
  

Mime
View raw message