You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mt...@apache.org on 2004/09/26 08:56:24 UTC

cvs commit: httpd-2.0/modules/proxy proxy_ajp.c proxy_http.c

mturk       2004/09/25 23:56:24

  Modified:    modules/proxy proxy_ajp.c proxy_http.c
  Log:
  Count the bytes trasfered and readed so we can display the actual
  data traffic, and add additional balancer mechanism that will use the
  data traffic into account.
  
  Revision  Changes    Path
  1.26      +8 -1      httpd-2.0/modules/proxy/proxy_ajp.c
  
  Index: proxy_ajp.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ajp.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- proxy_ajp.c	17 Sep 2004 17:02:28 -0000	1.25
  +++ proxy_ajp.c	26 Sep 2004 06:56:24 -0000	1.26
  @@ -118,6 +118,7 @@
       const char *tenc;
       int havebody=1;
       int isok=1;
  +    apr_off_t bb_len;
   
       /*
        * Send the AJP request to the remote server
  @@ -192,6 +193,7 @@
                                conn->worker->hostname);
                   return HTTP_SERVICE_UNAVAILABLE;
               }
  +            conn->worker->s->transfered += bufsiz;
           }
       }
   
  @@ -206,7 +208,6 @@
                        conn->worker->hostname);
           return HTTP_SERVICE_UNAVAILABLE;
       }
  -
       /* parse the reponse */
       result = ajp_parse_type(r, conn->data);
       output_brigade = apr_brigade_create(p, r->connection->bucket_alloc);
  @@ -248,6 +249,7 @@
                                        "ajp_send_data_msg failed");
                           break;
                       }
  +                    conn->worker->s->transfered += bufsiz;
                   } else {
                       /* something is wrong TC asks for more body but we are
                        * already at the end of the body data
  @@ -304,6 +306,11 @@
       	result = ajp_parse_type(r, conn->data);
       }
       apr_brigade_destroy(input_brigade);
  +
  +    apr_brigade_length(output_brigade, 0, &bb_len);
  +    if (bb_len != -1)
  +        conn->worker->s->readed += bb_len;
  +
       if (!isok)
           apr_brigade_destroy(output_brigade);
   
  
  
  
  1.200     +15 -6     httpd-2.0/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
  retrieving revision 1.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- proxy_http.c	14 Sep 2004 18:54:32 -0000	1.199
  +++ proxy_http.c	26 Sep 2004 06:56:24 -0000	1.200
  @@ -250,6 +250,7 @@
       int counter, seen_eos, send_chunks;
       apr_status_t status;
       apr_bucket_brigade *header_brigade, *body_brigade, *input_brigade;
  +    apr_off_t transfered = 0;
   
       header_brigade = apr_brigade_create(p, origin->bucket_alloc);
       body_brigade = apr_brigade_create(p, origin->bucket_alloc);
  @@ -482,7 +483,11 @@
       APR_BRIGADE_INSERT_TAIL(header_brigade, e);
       e = apr_bucket_flush_create(c->bucket_alloc);
       APR_BRIGADE_INSERT_TAIL(header_brigade, e);
  -
  +    
  +    apr_brigade_length(header_brigade, 0, &transfered);
  +    if (transfered != -1)
  +        conn->worker->s->transfered += transfered;
  +    conn->worker->s->transfered += transfered;
       if (send_chunks) {
           status = ap_pass_brigade(origin->output_filters, header_brigade);
   
  @@ -630,9 +635,11 @@
                         conn->worker->cp->addr, conn->hostname);
           return status;
       }
  - 
  -    apr_brigade_cleanup(body_brigade);
  +    apr_brigade_length(body_brigade, 0, &transfered);
  +    if (transfered != -1)
  +        conn->worker->s->transfered += transfered;
   
  +    apr_brigade_cleanup(body_brigade);
       return APR_SUCCESS;
   }
   static void process_proxy_header(request_rec* r, proxy_server_conf* c,
  @@ -803,7 +810,6 @@
        * response.
        */
       rp->proxyreq = PROXYREQ_RESPONSE;
  -
       do {
           apr_brigade_cleanup(bb);
   
  @@ -820,6 +826,8 @@
               return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                                    "Error reading from remote server");
           }
  +        /* XXX: Is this a real headers length send from remote? */
  +        backend->worker->s->readed += len;
   
          /* Is it an HTTP/1 response?
           * This is buggy if we ever see an HTTP/1.10
  @@ -1023,10 +1031,11 @@
                                         AP_MODE_READBYTES, 
                                         APR_BLOCK_READ, 
                                         conf->io_buffer_size) == APR_SUCCESS) {
  -#if DEBUGGING
  -                    {
                       apr_off_t readbytes;
                       apr_brigade_length(bb, 0, &readbytes);
  +                    backend->worker->s->readed += readbytes;
  +#if DEBUGGING
  +                    {
                       ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
                                    r->server, "proxy (PID %d): readbytes: %#x",
                                    getpid(), readbytes);