From: Mladen Turk Date: Sun, 26 Sep 2004 06:56:24 +0000 (+0000) Subject: Count the bytes trasfered and readed so we can display the actual X-Git-Tag: 2.1.1~206 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fc9189541ab8cdc075895748775ddd77823e850;p=thirdparty%2Fapache%2Fhttpd.git 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105294 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_ajp.c b/modules/proxy/proxy_ajp.c index 388c6b6f019..a0d7f279000 100644 --- a/modules/proxy/proxy_ajp.c +++ b/modules/proxy/proxy_ajp.c @@ -118,6 +118,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, 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 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, conn->worker->hostname); return HTTP_SERVICE_UNAVAILABLE; } + conn->worker->s->transfered += bufsiz; } } @@ -206,7 +208,6 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, 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 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, "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 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r, 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); diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index d1b960d71a1..14933bcd1fc 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -250,6 +250,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r, 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_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r, 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 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r, 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 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, * response. */ rp->proxyreq = PROXYREQ_RESPONSE; - do { apr_brigade_cleanup(bb); @@ -820,6 +826,8 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, 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 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r, 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);