[multiple] extern log_epoch_secs

replace srv->cur_ts
This commit is contained in:
Glenn Strauss 2019-12-04 01:35:27 -05:00
parent 409bba80b1
commit c8cd7cf49b
20 changed files with 84 additions and 87 deletions

View File

@ -348,9 +348,6 @@ struct server {
uint32_t max_conns;
/* Timestamps */
time_t cur_ts;
log_error_st *errh;
server_config srvconf;

View File

@ -418,7 +418,7 @@ handler_t connection_handle_read_post_state(connection *con) {
int is_closed = 0;
if (con->is_readable) {
con->read_idle_ts = con->srv->cur_ts;
con->read_idle_ts = log_epoch_secs;
switch(con->network_read(con, con->read_queue, MAX_READ_LIMIT)) {
case -1:

View File

@ -152,7 +152,7 @@ static int connection_close(server *srv, connection *con) {
return 0;
}
static void connection_read_for_eos_plain(connection * const con, const time_t cur_ts) {
static void connection_read_for_eos_plain(connection * const con) {
/* we have to do the linger_on_close stuff regardless
* of con->keep_alive; even non-keepalive sockets may
* still have unread data, and closing before reading
@ -172,26 +172,25 @@ static void connection_read_for_eos_plain(connection * const con, const time_t c
#endif
/* 0 == len || (len < 0 && (errno is a non-recoverable error)) */
con->close_timeout_ts = cur_ts - (HTTP_LINGER_TIMEOUT+1);
con->close_timeout_ts = log_epoch_secs - (HTTP_LINGER_TIMEOUT+1);
}
static void connection_read_for_eos_ssl(connection * const con, const time_t cur_ts) {
static void connection_read_for_eos_ssl(connection * const con) {
if (con->network_read(con, con->read_queue, MAX_READ_LIMIT) < 0)
con->close_timeout_ts = cur_ts - (HTTP_LINGER_TIMEOUT+1);
con->close_timeout_ts = log_epoch_secs - (HTTP_LINGER_TIMEOUT+1);
chunkqueue_reset(con->read_queue);
}
static void connection_read_for_eos(connection * const con, const time_t cur_ts) {
static void connection_read_for_eos(connection * const con) {
!con->is_ssl_sock
? connection_read_for_eos_plain(con, cur_ts)
: connection_read_for_eos_ssl(con, cur_ts);
? connection_read_for_eos_plain(con)
: connection_read_for_eos_ssl(con);
}
static void connection_handle_close_state(server *srv, connection *con) {
const time_t cur_ts = srv->cur_ts;
connection_read_for_eos(con, cur_ts);
connection_read_for_eos(con);
if (cur_ts - con->close_timeout_ts > HTTP_LINGER_TIMEOUT) {
if (log_epoch_secs - con->close_timeout_ts > HTTP_LINGER_TIMEOUT) {
connection_close(srv, con);
}
}
@ -206,7 +205,7 @@ static void connection_handle_shutdown(connection *con) {
/* close the connection */
if (con->fd >= 0
&& (con->is_ssl_sock || 0 == shutdown(con->fd, SHUT_WR))) {
con->close_timeout_ts = srv->cur_ts;
con->close_timeout_ts = log_epoch_secs;
connection_set_state(con, CON_STATE_CLOSE);
if (srv->srvconf.log_state_handling) {
@ -241,8 +240,7 @@ static void connection_handle_response_end_state(connection *con) {
if (con->keep_alive) {
connection_reset(con);
#if 0
con->request_start = con->srv->cur_ts;
con->read_idle_ts = con->srv->cur_ts;
con->request_start = con->read_idle_ts = log_epoch_secs;
#endif
connection_set_state(con, CON_STATE_REQUEST_START);
} else {
@ -485,7 +483,7 @@ static void connection_handle_write(connection *con) {
/* not finished yet -> WRITE */
break;
}
con->write_request_ts = con->srv->cur_ts;
con->write_request_ts = log_epoch_secs;
}
static void connection_handle_write_state(connection *con) {
@ -719,7 +717,7 @@ static void connection_discard_blank_line(connection *con, const char * const s,
static chunk * connection_read_header_more(connection *con, chunkqueue *cq, chunk *c, const size_t olen) {
if ((NULL == c || NULL == c->next) && con->is_readable) {
con->read_idle_ts = con->srv->cur_ts;
con->read_idle_ts = log_epoch_secs;
if (0 != con->network_read(con, cq, MAX_READ_LIMIT))
connection_set_state(con, CON_STATE_ERROR);
}
@ -816,11 +814,11 @@ static int connection_handle_read_state(server * const srv, connection * const c
if (0 != con->bytes_read) {
/* update request_start timestamp when first byte of
* next request is received on a keep-alive connection */
con->request_start = srv->cur_ts;
con->request_start = log_epoch_secs;
if (con->conf.high_precision_timestamps)
log_clock_gettime_realtime(&con->request_start_hp);
}
if (pipelined_request_start && c) con->read_idle_ts = srv->cur_ts;
if (pipelined_request_start && c) con->read_idle_ts = log_epoch_secs;
}
if (NULL == c) return 0; /* incomplete request headers */
@ -904,7 +902,7 @@ static handler_t connection_handle_fdevent(server *srv, void *context, int reven
if (con->state == CON_STATE_CLOSE) {
/* flush the read buffers */
connection_read_for_eos(con, srv->cur_ts);
connection_read_for_eos(con);
}
@ -913,7 +911,7 @@ static handler_t connection_handle_fdevent(server *srv, void *context, int reven
if ((revents & ~(FDEVENT_IN | FDEVENT_OUT)) && con->state != CON_STATE_ERROR) {
if (con->state == CON_STATE_CLOSE) {
con->close_timeout_ts = srv->cur_ts - (HTTP_LINGER_TIMEOUT+1);
con->close_timeout_ts = log_epoch_secs - (HTTP_LINGER_TIMEOUT+1);
} else if (revents & FDEVENT_HUP) {
connection_set_state(con, CON_STATE_ERROR);
} else if (revents & FDEVENT_RDHUP) {
@ -1118,7 +1116,7 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
connection_set_state(con, CON_STATE_REQUEST_START);
con->connection_start = srv->cur_ts;
con->connection_start = log_epoch_secs;
con->dst_addr = *cnt_addr;
buffer_copy_string(con->dst_addr_buf, inet_ntop_cache_get_ip(srv, &(con->dst_addr)));
con->srv_socket = srv_socket;
@ -1265,7 +1263,7 @@ int connection_state_machine(server *srv, connection *con) {
switch ((ostate = con->state)) {
case CON_STATE_REQUEST_START: /* transient */
con->request_start = con->read_idle_ts = srv->cur_ts;
con->request_start = con->read_idle_ts = log_epoch_secs;
if (con->conf.high_precision_timestamps)
log_clock_gettime_realtime(&con->request_start_hp);
@ -1374,10 +1372,10 @@ int connection_state_machine(server *srv, connection *con) {
if (r != events) {
/* update timestamps when enabling interest in events */
if ((r & FDEVENT_IN) && !(events & FDEVENT_IN)) {
con->read_idle_ts = srv->cur_ts;
con->read_idle_ts = log_epoch_secs;
}
if ((r & FDEVENT_OUT) && !(events & FDEVENT_OUT)) {
con->write_request_ts = srv->cur_ts;
con->write_request_ts = log_epoch_secs;
}
fdevent_fdnode_event_set(srv->ev, con->fdn, r);
}
@ -1491,7 +1489,7 @@ void connection_graceful_shutdown_maint (server *srv) {
* (from zero) *up to* one more second, but no more */
if (HTTP_LINGER_TIMEOUT > 1)
con->close_timeout_ts -= (HTTP_LINGER_TIMEOUT - 1);
if (srv->cur_ts - con->close_timeout_ts > HTTP_LINGER_TIMEOUT)
if (log_epoch_secs - con->close_timeout_ts > HTTP_LINGER_TIMEOUT)
changed = 1;
}
else if (con->state == CON_STATE_READ && con->request_count > 1

View File

@ -213,7 +213,7 @@ static int gw_extension_insert(gw_exts *ext, const buffer *key, gw_host *fh) {
static void gw_proc_connect_success(connection *con, gw_host *host, gw_proc *proc, int debug) {
gw_proc_tag_inc(host, proc, CONST_STR_LEN(".connected"));
proc->last_used = con->srv->cur_ts;
proc->last_used = log_epoch_secs;
if (debug) {
log_error(con->conf.errh, __FILE__, __LINE__,
@ -224,7 +224,7 @@ static void gw_proc_connect_success(connection *con, gw_host *host, gw_proc *pro
__attribute_cold__
static void gw_proc_connect_error(connection *con, gw_host *host, gw_proc *proc, pid_t pid, int errnum, int debug) {
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
log_error_st * const errh = con->conf.errh;
log_error(errh, __FILE__, __LINE__,
"establishing connection failed: socket: %s: %s",
@ -298,7 +298,7 @@ static void gw_proc_release(gw_host *host, gw_proc *proc, int debug, log_error_s
}
static void gw_proc_check_enable(server *srv, gw_host *host, gw_proc *proc) {
if (srv->cur_ts <= proc->disabled_until) return;
if (log_epoch_secs <= proc->disabled_until) return;
if (proc->state != PROC_STATE_OVERLOADED) return;
gw_proc_set_state(host, proc, PROC_STATE_RUNNING);
@ -353,7 +353,7 @@ static int gw_proc_waitpid(server *srv, gw_host *host, gw_proc *proc) {
proc->pid = 0;
if (proc->state != PROC_STATE_KILLED)
proc->disabled_until = srv->cur_ts;
proc->disabled_until = log_epoch_secs;
gw_proc_set_state(host, proc, PROC_STATE_DIED);
return 1;
}
@ -572,12 +572,12 @@ static int gw_spawn_connection(server *srv, gw_host *host, gw_proc *proc, int de
log_error(srv->errh, __FILE__, __LINE__,
"gw-backend failed to start: %s", host->bin_path->ptr);
proc->pid = 0;
proc->disabled_until = srv->cur_ts;
proc->disabled_until = log_epoch_secs;
return -1;
}
/* register process */
proc->last_used = srv->cur_ts;
proc->last_used = log_epoch_secs;
proc->is_local = 1;
/* wait */
@ -614,7 +614,7 @@ static void gw_proc_spawn(server *srv, gw_host *host, int debug) {
/* (proc->pid <= 0 indicates PROC_STATE_DIED, not PROC_STATE_KILLED) */
if (proc->pid > 0) continue;
/* (do not attempt to spawn another proc if a proc just exited) */
if (proc->disabled_until >= srv->cur_ts) return;
if (proc->disabled_until >= log_epoch_secs) return;
break;
}
if (proc) {
@ -995,7 +995,7 @@ static void gw_restart_dead_procs(server *srv, gw_host *host, int debug, int tri
/*(state should not happen in workers if server.max-worker > 0)*/
/*(if PROC_STATE_DIED_WAIT_FOR_PID is used in future, might want
* to save proc->disabled_until before gw_proc_waitpid() since
* gw_proc_waitpid will set proc->disabled_until to srv->cur_ts,
* gw_proc_waitpid will set proc->disabled_until to log_epoch_secs,
* and so process will not be restarted below until one sec later)*/
if (0 == gw_proc_waitpid(srv, host, proc)) {
gw_proc_check_enable(srv, host, proc);
@ -1014,7 +1014,7 @@ static void gw_restart_dead_procs(server *srv, gw_host *host, int debug, int tri
if (proc->load != 0) break;
/* avoid spinning if child exits too quickly */
if (proc->disabled_until >= srv->cur_ts) break;
if (proc->disabled_until >= log_epoch_secs) break;
/* restart the child */
@ -1723,7 +1723,7 @@ int gw_get_defaults_balance(server *srv, const buffer *b) {
static void gw_set_state(gw_handler_ctx *hctx, gw_connection_state_t state) {
hctx->state = state;
/*hctx->state_timestamp = hctx->remote_conn->srv->cur_ts;*/
/*hctx->state_timestamp = log_epoch_secs;*/
}
@ -2144,7 +2144,7 @@ static handler_t gw_recv_response(gw_handler_ctx *hctx, connection *con) {
physpath = con->physical.path;
}
proc->last_used = con->srv->cur_ts;
proc->last_used = log_epoch_secs;
gw_backend_close(hctx, con);
handler_ctx_clear(hctx);
@ -2185,7 +2185,7 @@ static handler_t gw_recv_response(gw_handler_ctx *hctx, connection *con) {
&& proc->state != PROC_STATE_DIED
&& 0 == con->srv->srvconf.max_worker) {
/* intentionally check proc->disabed_until before gw_proc_waitpid */
if (proc->disabled_until < con->srv->cur_ts
if (proc->disabled_until < log_epoch_secs
&& 0 != gw_proc_waitpid(con->srv, host, proc)) {
if (hctx->conf.debug) {
log_error(errh, __FILE__, __LINE__,
@ -2560,7 +2560,7 @@ static void gw_handle_trigger_host(server *srv, gw_host *host, int debug) {
gw_proc_spawn(srv, host, debug);
}
idle_timestamp = srv->cur_ts - host->idle_timeout;
idle_timestamp = log_epoch_secs - host->idle_timeout;
for (proc = host->first; proc; proc = proc->next) {
if (host->num_procs <= host->min_procs) break;
if (0 != proc->load) continue;
@ -2676,7 +2676,7 @@ handler_t gw_handle_waitpid_cb(server *srv, void *p_d, pid_t pid, int status) {
* or global scope (for convenience))
* (unable to use p->defaults.debug since gw_plugin_config
* might be part of a larger plugin_config) */
const time_t cur_ts = srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
gw_exts *exts = conf->exts;
for (uint32_t j = 0; j < exts->used; ++j) {
gw_extension *ex = exts->exts+j;

View File

@ -27,6 +27,8 @@
#endif
#endif
time_t log_epoch_secs = 0;
int log_clock_gettime_realtime (struct timespec *ts) {
#ifdef HAVE_CLOCK_GETTIME
return clock_gettime(CLOCK_REALTIME, ts);
@ -81,8 +83,8 @@ static int log_buffer_prepare(const log_error_st *errh, const char *filename, un
case ERRORLOG_FD:
if (-1 == errh->errorlog_fd) return -1;
/* cache the generated timestamp */
if (tlast != *errh->cur_ts) {
tlast = *errh->cur_ts;
if (tlast != log_epoch_secs) {
tlast = log_epoch_secs;
tlen = strftime(tstr, sizeof(tstr),
"%Y-%m-%d %H:%M:%S", localtime(&tlast));
}
@ -249,14 +251,13 @@ log_error_multiline_buffer (const log_error_st * const restrict errh,
log_error_st *
log_error_st_init (time_t *cur_ts_ptr)
log_error_st_init (void)
{
log_error_st *errh = calloc(1, sizeof(log_error_st));
force_assert(errh);
errh->errorlog_fd = STDERR_FILENO;
errh->errorlog_mode = ERRORLOG_FD;
errh->b = buffer_init();
errh->cur_ts = cur_ts_ptr;
return errh;
}

View File

@ -5,6 +5,8 @@
#include "base_decls.h"
#include "buffer.h"
extern time_t log_epoch_secs;
struct timespec; /* declaration */
int log_clock_gettime_realtime (struct timespec *ts);
@ -14,11 +16,10 @@ struct log_error_st {
enum { ERRORLOG_FILE, ERRORLOG_FD, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode;
int errorlog_fd;
buffer *b;
time_t *cur_ts;
};
__attribute_cold__
log_error_st * log_error_st_init (time_t *cur_ts_ptr);
log_error_st * log_error_st_init (void);
__attribute_cold__
void log_error_st_free (log_error_st *errh);

View File

@ -733,9 +733,10 @@ static void log_access_flush(plugin_data * const p) {
}
TRIGGER_FUNC(log_access_periodic_flush) {
/* flush buffered access logs every 4 seconds */
if (0 == (srv->cur_ts & 3)) log_access_flush((plugin_data *)p_d);
return HANDLER_GO_ON;
/* flush buffered access logs every 4 seconds */
if (0 == (log_epoch_secs & 3)) log_access_flush((plugin_data *)p_d);
UNUSED(srv);
return HANDLER_GO_ON;
}
SIGHUP_FUNC(log_access_cycle) {
@ -798,7 +799,7 @@ REQUESTDONE_FUNC(log_access_write) {
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)) ? con->srv->cur_ts : con->request_start;
time_t t = (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) ? log_epoch_secs : con->request_start;
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)*/
@ -863,7 +864,7 @@ REQUESTDONE_FUNC(log_access_write) {
#endif /* HAVE_STRUCT_TM_GMTOFF */
if (!(f->opt & FORMAT_FLAG_TIME_BEGIN)) {
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
if (parsed_format->last_generated_accesslog_ts == cur_ts) {
buffer_append_string_buffer(b, ts_accesslog_str);
break;
@ -920,7 +921,7 @@ REQUESTDONE_FUNC(log_access_write) {
case FORMAT_TIME_USED:
case FORMAT_TIME_USED_US:
if (f->opt & FORMAT_FLAG_TIME_SEC) {
buffer_append_int(b, con->srv->cur_ts - con->request_start);
buffer_append_int(b, log_epoch_secs - con->request_start);
} else {
const struct timespec * const bs = &con->request_start_hp;
off_t tdiff; /*(expected to be 64-bit since large file support enabled)*/

View File

@ -1171,7 +1171,7 @@ static handler_t mod_auth_check_digest(connection *con, void *p_d, const struct
for (i = 0; i < 8 && light_isxdigit(nonce_uns[i]); ++i) {
ts = (ts << 4) + hex2int(nonce_uns[i]);
}
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
if (nonce[i] != ':'
|| ts > cur_ts || cur_ts - ts > 600) { /*(10 mins)*/
/* nonce is stale; have client regenerate digest */
@ -1197,7 +1197,7 @@ static handler_t mod_auth_check_digest(connection *con, void *p_d, const struct
static handler_t mod_auth_send_401_unauthorized_digest(connection *con, const struct http_auth_require_t *require, int nonce_stale) {
server *srv = con->srv;
mod_auth_digest_www_authenticate(srv->tmp_buf, srv->cur_ts, require, nonce_stale);
mod_auth_digest_www_authenticate(srv->tmp_buf, log_epoch_secs, require, nonce_stale);
http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(srv->tmp_buf));
con->http_status = 401;

View File

@ -307,7 +307,7 @@ CONNECTION_FUNC(mod_expire_handler) {
if (NULL != vb) {
time_t ts, expires;
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
stat_cache_entry *sce = NULL;
switch(mod_expire_get_offset(con->conf.errh, vb, &ts)) {

View File

@ -357,7 +357,7 @@ static int mod_rrd_write_data(server *srv, plugin_data *p, rrd_config *s) {
s->bytes_read = 0;
}
else if (!(strstr(resp, "(minimum one second step)")
&& srv->cur_ts - srv->startup_ts < 3)) {
&& log_epoch_secs - srv->startup_ts < 3)) {
/* don't fail on this error if we just started (above condition)
* (graceful restart, the old one might have just updated too) */
log_error(srv->errh, __FILE__, __LINE__,
@ -391,7 +391,7 @@ TRIGGER_FUNC(mod_rrd_trigger) {
if (0 == p->rrdtool_pid) return HANDLER_GO_ON;
/* write data once a minute */
if ((srv->cur_ts % 60) != 0) return HANDLER_GO_ON;
if ((log_epoch_secs % 60) != 0) return HANDLER_GO_ON;
if (!p->rrdtool_running) {
if (srv->pid != p->srv_pid) return HANDLER_GO_ON;

View File

@ -470,7 +470,7 @@ URIHANDLER_FUNC(mod_secdownload_uri_handler) {
ts = (ts << 4) + hex2int(ts_str[i]);
}
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
/* timed-out */
if ( (cur_ts > ts && (unsigned int) (cur_ts - ts) > p->conf.timeout) ||

View File

@ -179,7 +179,7 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c
char multiplier = '\0';
char buf[32];
time_t ts;
const time_t cur_ts = srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
int days, hours, mins, seconds;
@ -590,7 +590,7 @@ static handler_t mod_status_handle_server_status_text(server *srv, connection *c
/* output uptime */
buffer_append_string_len(b, CONST_STR_LEN("Uptime: "));
buffer_append_int(b, srv->cur_ts - srv->startup_ts);
buffer_append_int(b, log_epoch_secs - srv->startup_ts);
buffer_append_string_len(b, CONST_STR_LEN("\n"));
/* output busy servers */
@ -664,7 +664,7 @@ static handler_t mod_status_handle_server_status_json(server *srv, connection *c
/* output uptime */
buffer_append_string_len(b, CONST_STR_LEN("\t\"Uptime\": "));
buffer_append_int(b, srv->cur_ts - srv->startup_ts);
buffer_append_int(b, log_epoch_secs - srv->startup_ts);
buffer_append_string_len(b, CONST_STR_LEN(",\n"));
/* output busy servers */

View File

@ -397,7 +397,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) {
log_error(con->conf.errh, __FILE__, __LINE__, "(debug) remote-ip: %s", remote_ip->ptr);
}
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
/* check if URL is a trigger -> insert IP into DB */
if ((n = pcre_exec(p->conf.trigger_regex, NULL, CONST_BUF_LEN(con->uri.path), 0, 0, ovec, 3 * N)) < 0) {
@ -560,8 +560,9 @@ static void mod_trigger_b4_dl_trigger_gdbm(GDBM_FILE db, const time_t cur_ts, co
TRIGGER_FUNC(mod_trigger_b4_dl_handle_trigger) {
/* check DB each minute */
const time_t cur_ts = srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
if (cur_ts % 60 != 0) return HANDLER_GO_ON;
UNUSED(srv);
plugin_data * const p = p_d;

View File

@ -168,7 +168,7 @@ static handler_t mod_usertrack_set_cookie(connection *con, plugin_data *p) {
li_MD5_Update(&Md5Ctx, CONST_BUF_LEN(con->uri.path));
li_MD5_Update(&Md5Ctx, CONST_STR_LEN("+"));
len = li_itostrn(hh, sizeof(hh), con->srv->cur_ts);
len = li_itostrn(hh, sizeof(hh), log_epoch_secs);
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, len);
len = li_itostrn(hh, sizeof(hh), li_rand_pseudo());
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, len);

View File

@ -377,7 +377,7 @@ static handler_t wstunnel_create_env(gw_handler_ctx *gwhctx) {
con->http_status = 101; /* Switching Protocols */
con->file_started = 1;
hctx->ping_ts = con->srv->cur_ts;
hctx->ping_ts = log_epoch_secs;
gw_set_transparent(&hctx->gw);
return HANDLER_GO_ON;
@ -604,7 +604,7 @@ static handler_t mod_wstunnel_check_extension(connection *con, void *p_d) {
TRIGGER_FUNC(mod_wstunnel_handle_trigger) {
const plugin_data * const p = p_d;
const time_t cur_ts = srv->cur_ts + 1;
const time_t cur_ts = log_epoch_secs + 1;
gw_handle_trigger(srv, p_d);

View File

@ -103,7 +103,7 @@ int http_response_write_header(connection *con) {
buffer_append_string_len(b, CONST_STR_LEN("\r\nDate: "));
/* cache the generated timestamp */
const time_t cur_ts = con->srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
if (tlast != cur_ts) {
tlast = cur_ts;
tlen = strftime(tstr, sizeof(tstr),

View File

@ -246,10 +246,9 @@ static server *server_init(void) {
li_rand_reseed();
srv->cur_ts = time(NULL);
srv->startup_ts = srv->cur_ts;
srv->startup_ts = log_epoch_secs = time(NULL);
srv->errh = log_error_st_init(&srv->cur_ts);
srv->errh = log_error_st_init();
config_init(srv);
@ -1418,7 +1417,7 @@ static int server_main (server * const srv, int argc, char **argv) {
int status;
if (-1 != (pid = wait(&status))) {
srv->cur_ts = time(NULL);
log_epoch_secs = time(NULL);
if (plugins_call_handle_waitpid(srv, pid, status) != HANDLER_GO_ON) {
if (!timer) alarm((timer = 5));
continue;
@ -1442,7 +1441,7 @@ static int server_main (server * const srv, int argc, char **argv) {
} else {
switch (errno) {
case EINTR:
srv->cur_ts = time(NULL);
log_epoch_secs = time(NULL);
/**
* if we receive a SIGHUP we have to close our logs ourself as we don't
* have the mainloop who can help us here
@ -1461,7 +1460,7 @@ static int server_main (server * const srv, int argc, char **argv) {
handle_sig_alarm = 0;
timer = 0;
plugins_call_handle_trigger(srv);
fdevent_restart_logger_pipes(srv->cur_ts);
fdevent_restart_logger_pipes(log_epoch_secs);
}
break;
default:
@ -1620,7 +1619,7 @@ static void server_handle_sigalrm (server * const srv, time_t min_ts, time_t las
plugins_call_handle_trigger(srv);
srv->cur_ts = min_ts;
log_epoch_secs = min_ts;
/* check idle time limit, if enabled */
if (idle_limit && idle_limit < min_ts - last_active_ts && !graceful_shutdown) {
@ -1667,7 +1666,7 @@ static void server_handle_sigchld (server * const srv) {
}
if (0 == srv->srvconf.max_worker) {
/* check piped-loggers and restart, even if shutting down */
if (fdevent_waitpid_logger_pipe_pid(pid, srv->cur_ts)) {
if (fdevent_waitpid_logger_pipe_pid(pid, log_epoch_secs)) {
continue;
}
}
@ -1694,7 +1693,7 @@ static int server_main_loop (server * const srv) {
handle_sig_alarm = 0;
#endif
time_t min_ts = time(NULL);
if (min_ts != srv->cur_ts) {
if (min_ts != log_epoch_secs) {
server_handle_sigalrm(srv, min_ts, last_active_ts);
}
#ifdef USE_ALARM
@ -1725,7 +1724,7 @@ static int server_main_loop (server * const srv) {
}
if (fdevent_poll(srv->ev, 1000) > 0) {
last_active_ts = srv->cur_ts;
last_active_ts = log_epoch_secs;
}
for (uint32_t ndx = 0; ndx < joblist->used; ++ndx) {

View File

@ -430,7 +430,7 @@ static fam_dir_entry * fam_dir_monitor(server *srv, stat_cache_fam *scf, char *f
/* directory already registered */
}
const time_t cur_ts = srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
struct stat lst;
int ck_dir = fn_is_dir;
if (!fn_is_dir && (NULL==fam_dir || cur_ts - fam_dir->stat_ts >= 16)) {
@ -733,7 +733,7 @@ void stat_cache_update_entry(server *srv, const char *name, size_t len,
stat_cache_entry *sce =
stat_cache_sptree_find(sptree, name, len);
if (sce && buffer_is_equal_string(sce->name, name, len)) {
sce->stat_ts = srv->cur_ts;
sce->stat_ts = log_epoch_secs;
sce->st = *st; /* etagb might be NULL to clear etag (invalidate) */
buffer_copy_string_len(sce->etag, CONST_BUF_LEN(etagb));
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
@ -894,7 +894,7 @@ handler_t stat_cache_get_entry(connection *con, buffer *name, stat_cache_entry *
*/
server * const srv = con->srv;
const time_t cur_ts = srv->cur_ts;
const time_t cur_ts = log_epoch_secs;
sc = srv->stat_cache;
@ -1114,7 +1114,7 @@ int stat_cache_trigger_cleanup(server *srv) {
#ifdef HAVE_FAM_H
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
if (srv->cur_ts & 0x1F) return 0;
if (log_epoch_secs & 0x1F) return 0;
/* once every 32 seconds (0x1F == 31) */
max_age = 32;
fam_dir_periodic_cleanup(srv);
@ -1125,7 +1125,7 @@ int stat_cache_trigger_cleanup(server *srv) {
}
#endif
stat_cache_periodic_cleanup(srv->stat_cache, max_age, srv->cur_ts);
stat_cache_periodic_cleanup(srv->stat_cache, max_age, log_epoch_secs);
return 0;
}

View File

@ -13,10 +13,9 @@
#ifdef HAVE_PCRE_H
static pcre_keyvalue_buffer * test_keyvalue_test_kvb_init (void) {
static time_t cur_ts;
pcre_keyvalue_buffer *kvb = pcre_keyvalue_buffer_init();
log_error_st * const errh = log_error_st_init(&cur_ts);
log_error_st * const errh = log_error_st_init();
/* strings must be persistent for pcre_keyvalue_buffer_append() */
static const buffer kvstr[] = {

View File

@ -581,7 +581,7 @@ int main (void)
connection con;
memset(&srv, 0, sizeof(server));
srv.errh = log_error_st_init(&srv.cur_ts);
srv.errh = log_error_st_init();
srv.errh->errorlog_fd = -1; /* (disable) */
memset(&con, 0, sizeof(connection));