summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-08-10 06:46:49 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-08-10 06:46:49 -0400
commit8228273473a9feb804e813d3160d4b46c38eb3b1 (patch)
tree94849bf2e2691937eafe56e3c6fbfdc5e2b9eebc
parentca7a97f2111c051ae599a9e9e2243a9dcc54f601 (diff)
downloadlighttpd1.4-8228273473a9feb804e813d3160d4b46c38eb3b1.tar.gz
lighttpd1.4-8228273473a9feb804e813d3160d4b46c38eb3b1.zip
[mod_accesslog] flush access logs every 4 seconds
-rw-r--r--src/mod_accesslog.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c
index 9e299397..3e6773ce 100644
--- a/src/mod_accesslog.c
+++ b/src/mod_accesslog.c
@@ -649,12 +649,10 @@ SETDEFAULTS_FUNC(log_access_open) {
#define O_LARGEFILE 0
#endif
-SIGHUP_FUNC(log_access_cycle) {
+static void log_access_flush(server *srv, void *p_d) {
plugin_data *p = p_d;
size_t i;
- if (!p->config_storage) return HANDLER_GO_ON;
-
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s = p->config_storage[i];
@@ -665,7 +663,25 @@ SIGHUP_FUNC(log_access_cycle) {
buffer_reset(s->access_logbuffer);
}
+ }
+}
+TRIGGER_FUNC(log_access_periodic_flush) {
+ /* flush buffered access logs every 4 seconds */
+ if (0 == (srv->cur_ts & 3)) log_access_flush(srv, p_d);
+ return HANDLER_GO_ON;
+}
+
+SIGHUP_FUNC(log_access_cycle) {
+ plugin_data *p = p_d;
+ size_t i;
+
+ if (!p->config_storage) return HANDLER_GO_ON;
+
+ log_access_flush(srv, p);
+
+ for (i = 0; i < srv->config_context->used; i++) {
+ plugin_config *s = p->config_storage[i];
if (s->use_syslog == 0
&& !buffer_string_is_empty(s->access_logfile)
&& s->access_logfile->ptr[0] != '|') {
@@ -1126,6 +1142,7 @@ int mod_accesslog_plugin_init(plugin *p) {
p->cleanup = mod_accesslog_free;
p->handle_request_done = log_access_write;
+ p->handle_trigger = log_access_periodic_flush;
p->handle_sighup = log_access_cycle;
p->data = NULL;