Browse Source

[core] move request start ts into (request_st *)

move request start timestamps into (request_st *)
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
6fe031ef37
  1. 2
      src/base.h
  2. 12
      src/connections.c
  3. 14
      src/mod_accesslog.c
  4. 2
      src/mod_status.c
  5. 4
      src/request.h

2
src/base.h

@ -75,8 +75,6 @@ struct connection {
time_t write_request_ts;
time_t connection_start;
time_t request_start;
struct timespec request_start_hp;
uint32_t request_count; /* number of requests handled in this connection */
uint32_t loops_per_request; /* to catch endless loops in a single request

12
src/connections.c

@ -238,7 +238,7 @@ static void connection_handle_response_end_state(connection *con) {
if (con->request.keep_alive) {
connection_reset(con);
#if 0
con->request_start = con->read_idle_ts = log_epoch_secs;
con->request.start_ts = con->read_idle_ts = log_epoch_secs;
#endif
connection_set_state(con, CON_STATE_REQUEST_START);
} else {
@ -807,11 +807,11 @@ static int connection_handle_read_state(connection * const con) {
if (keepalive_request_start) {
if (0 != con->bytes_read) {
/* update request_start timestamp when first byte of
/* update con->request.start_ts timestamp when first byte of
* next request is received on a keep-alive connection */
con->request_start = log_epoch_secs;
con->request.start_ts = log_epoch_secs;
if (con->conf.high_precision_timestamps)
log_clock_gettime_realtime(&con->request_start_hp);
log_clock_gettime_realtime(&con->request.start_hp);
}
if (pipelined_request_start && c) con->read_idle_ts = log_epoch_secs;
}
@ -1258,9 +1258,9 @@ int connection_state_machine(connection *con) {
switch ((ostate = con->state)) {
case CON_STATE_REQUEST_START: /* transient */
con->request_start = con->read_idle_ts = log_epoch_secs;
con->request.start_ts = con->read_idle_ts = log_epoch_secs;
if (con->conf.high_precision_timestamps)
log_clock_gettime_realtime(&con->request_start_hp);
log_clock_gettime_realtime(&con->request.start_hp);
con->request_count++;
con->loops_per_request = 0;

14
src/mod_accesslog.c

@ -788,7 +788,7 @@ static int log_access_record (const connection * const con, buffer * const b, fo
if (f->opt & ~(FORMAT_FLAG_TIME_BEGIN|FORMAT_FLAG_TIME_END)) {
if (f->opt & FORMAT_FLAG_TIME_SEC) {
time_t t = (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) ? log_epoch_secs : con->request_start;
time_t t = (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) ? log_epoch_secs : con->request.start_ts;
buffer_append_int(b, (intmax_t)t);
} else if (f->opt & (FORMAT_FLAG_TIME_MSEC|FORMAT_FLAG_TIME_USEC|FORMAT_FLAG_TIME_NSEC)) {
off_t t; /*(expected to be 64-bit since large file support enabled)*/
@ -798,8 +798,8 @@ static int log_access_record (const connection * const con, buffer * const b, fo
t = (off_t)ts.tv_sec;
ns = ts.tv_nsec;
} else {
t = (off_t)con->request_start_hp.tv_sec;
ns = con->request_start_hp.tv_nsec;
t = (off_t)con->request.start_hp.tv_sec;
ns = con->request.start_hp.tv_nsec;
}
if (f->opt & FORMAT_FLAG_TIME_MSEC) {
t *= 1000;
@ -819,7 +819,7 @@ static int log_access_record (const connection * const con, buffer * const b, fo
if (0 == ts.tv_sec) log_clock_gettime_realtime(&ts);
ns = ts.tv_nsec;
} else {
ns = con->request_start_hp.tv_nsec;
ns = con->request.start_hp.tv_nsec;
}
/*assert(t < 1000000000);*/
if (f->opt & FORMAT_FLAG_TIME_MSEC_FRAC) {
@ -860,7 +860,7 @@ static int log_access_record (const connection * const con, buffer * const b, fo
t = parsed_format->last_generated_accesslog_ts = cur_ts;
flush = 1;
} else {
t = con->request_start;
t = con->request.start_ts;
}
#if defined(HAVE_STRUCT_TM_GMTOFF)
@ -909,9 +909,9 @@ static int log_access_record (const connection * const con, buffer * const b, fo
case FORMAT_TIME_USED:
case FORMAT_TIME_USED_US:
if (f->opt & FORMAT_FLAG_TIME_SEC) {
buffer_append_int(b, log_epoch_secs - con->request_start);
buffer_append_int(b, log_epoch_secs - con->request.start_ts);
} else {
const struct timespec * const bs = &con->request_start_hp;
const struct timespec * const bs = &con->request.start_hp;
off_t tdiff; /*(expected to be 64-bit since large file support enabled)*/
if (0 == ts.tv_sec) log_clock_gettime_realtime(&ts);
tdiff = (off_t)(ts.tv_sec - bs->tv_sec)*1000000000 + (ts.tv_nsec - bs->tv_nsec);

2
src/mod_status.c

@ -517,7 +517,7 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c
buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">"));
buffer_append_int(b, cur_ts - c->request_start);
buffer_append_int(b, cur_ts - c->request.start_ts);
buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">"));

4
src/request.h

@ -2,6 +2,8 @@
#define _REQUEST_H_
#include "first.h"
#include <time.h> /* (struct timespec) */
#include "base_decls.h"
#include "buffer.h"
#include "array.h"
@ -93,6 +95,8 @@ struct request_st {
off_t te_chunked;
int keep_alive; /* only request.c can enable it, all other just disable */
time_t start_ts;
struct timespec start_hp;
/* internal */
buffer *pathinfo;

Loading…
Cancel
Save