summaryrefslogtreecommitdiff
path: root/src/mod_accesslog.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2020-07-31 03:43:19 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2020-10-03 09:05:38 -0400
commitafc2025d8edba323453033dadf10469011ddcf8a (patch)
tree30c667c8b97a851386464c47712eda81e0313f4e /src/mod_accesslog.c
parent8eea3bd014efefd0258f43e7b18e12574ed1bb08 (diff)
downloadlighttpd-git-afc2025d8edba323453033dadf10469011ddcf8a.tar.gz
[core] reset connection counters per connection
reset connection counters per connection, not per request adjust mod_accesslog and mod_rrdtool usage continue to count mod_rrdtool per request rather than per connection so that data is updated after each request, rather than aggregated to the end of a potentially long-lived connection with many keep-alives.
Diffstat (limited to 'src/mod_accesslog.c')
-rw-r--r--src/mod_accesslog.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c
index 5986451a..05fd3bc0 100644
--- a/src/mod_accesslog.c
+++ b/src/mod_accesslog.c
@@ -981,13 +981,16 @@ static int log_access_record (const request_st * const r, buffer * const b, form
break;
case FORMAT_BYTES_OUT_NO_HEADER:
- if (con->bytes_written > 0) {
- off_t bytes = con->bytes_written - (off_t)r->resp_header_len;
+ {
+ off_t bytes = con->bytes_written - r->bytes_written_ckpt;
+ if (bytes > 0) {
+ bytes -= (off_t)r->resp_header_len;
buffer_append_int(b, bytes > 0 ? bytes : 0);
} else {
buffer_append_string_len(b, CONST_STR_LEN("-"));
}
break;
+ }
case FORMAT_HEADER:
if (NULL != (vb = http_header_request_get(r, HTTP_HEADER_UNSPECIFIED, CONST_BUF_LEN(&f->string)))) {
accesslog_append_escaped(b, vb);
@@ -1018,19 +1021,25 @@ static int log_access_record (const request_st * const r, buffer * const b, form
}
break;
case FORMAT_BYTES_OUT:
- if (con->bytes_written > 0) {
- buffer_append_int(b, con->bytes_written);
+ {
+ off_t bytes = con->bytes_written - r->bytes_written_ckpt;
+ if (bytes > 0) {
+ buffer_append_int(b, bytes);
} else {
buffer_append_string_len(b, CONST_STR_LEN("-"));
}
break;
+ }
case FORMAT_BYTES_IN:
- if (con->bytes_read > 0) {
- buffer_append_int(b, con->bytes_read);
+ {
+ off_t bytes = con->bytes_read - r->bytes_read_ckpt;
+ if (bytes > 0) {
+ buffer_append_int(b, bytes);
} else {
buffer_append_string_len(b, CONST_STR_LEN("-"));
}
break;
+ }
case FORMAT_SERVER_NAME:
if (!buffer_string_is_empty(r->server_name)) {
buffer_append_string_buffer(b, r->server_name);