Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mmap buffer, add mmap buffer support to access log and userspace utility (#537) #2273

Merged
merged 120 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
a9ddf9d
Add a ring buffer mapped to userspace
ai-tmpst Oct 10, 2024
7563594
Add tests for the ring buffer mapped to userspace
ai-tmpst Oct 21, 2024
c12d99a
Remove trailing tabs in access_log.c
ai-tmpst Oct 2, 2024
45981e0
Use alloc_percpu_gfp() in mmap_buffer
ai-tmpst Oct 24, 2024
be7743e
Fix memory leak of holder->buf in mmap_buffer
ai-tmpst Oct 24, 2024
e6dffe7
Fix indentation in mmap_buffer
ai-tmpst Oct 25, 2024
9c8868b
mmap_buffer: Map data area twice to handle end-boundary wrapping
ai-tmpst Oct 30, 2024
471f6d6
mmap_buffer: Rewrote tests according the new API
ai-tmpst Oct 30, 2024
711ea13
Add mmap buffer support for access logging
ai-tmpst Oct 30, 2024
c3e0292
Add userspace utility to read mmap buffer and send logs to ClickHouse
ai-tmpst Oct 30, 2024
bc07388
tfw_logger: Rename *.cpp files to *.cc
ai-tmpst Nov 4, 2024
1549ff7
tfw_logger: Add copyrights
ai-tmpst Nov 4, 2024
a8218d2
tfw_logger: Fix includes order
ai-tmpst Nov 4, 2024
fc62d9d
mmap_buffer: Check alloc_percpu_gfp return
ai-tmpst Nov 4, 2024
6d24580
mmap_buffer: Handle errors for class and device creation
ai-tmpst Nov 4, 2024
2c26e3a
mmap_buffer: Add a test for device creation
ai-tmpst Nov 4, 2024
d5b92ef
tfw_logger: Move thread work outside the buffer reader
ai-tmpst Nov 5, 2024
892cf22
tfw_logger: Make TfwClickhouse single-threaded
ai-tmpst Nov 5, 2024
f29a8dd
tfw_logger: Get rid of `using namespace`
ai-tmpst Nov 5, 2024
405c97f
tfw_logger: Delete copy and move constructors
ai-tmpst Nov 5, 2024
04f884f
tfw_logger: Fix NOW_MS define
ai-tmpst Nov 5, 2024
db3110e
tfw_logger: Annotate private class members with `_`
ai-tmpst Nov 5, 2024
cf687a4
tfw_logger: Change column creation
ai-tmpst Nov 6, 2024
891f71d
tfw_logger: Add appropriate exceptions handling
ai-tmpst Nov 6, 2024
d1e6c3b
tfw_logger: Remove the main loop
ai-tmpst Nov 6, 2024
03801c7
tfw_logger: Get rid of memory barrier
ai-tmpst Nov 6, 2024
f79ebfa
tfw_logger: Rewrite hexdump using ostringstream
ai-tmpst Nov 6, 2024
2301a5b
access_log: Use absolute timestamp since epoch
ai-tmpst Nov 6, 2024
b018e18
tfw_logger: Store timestamp as DateTime64
ai-tmpst Nov 6, 2024
7d8d7e2
access_log,tfw_logger: Send dropped events number as a field
ai-tmpst Nov 6, 2024
aded786
tfw_logger: Replace output to cerr by exceptions
ai-tmpst Nov 6, 2024
9f67660
tfw_logger: Use boost for erguments handling
ai-tmpst Nov 6, 2024
d5a38c7
tfw_logger: Add 'ncpu' argument handling
ai-tmpst Nov 6, 2024
299f310
tfw_logger: Add signals handling
ai-tmpst Nov 7, 2024
b9d9533
access_log: Remove unnecessary mmap_buffer checks
ai-tmpst Nov 7, 2024
6388cc2
access_log: Remove field presence checks
ai-tmpst Nov 7, 2024
98e0ded
access_log: Replace memcpy_fast calls by assignments for short fields
ai-tmpst Nov 7, 2024
6d5f04a
access_log: Move dmesg log code to a separate function
ai-tmpst Nov 7, 2024
c951478
access_log: Fix response time calculation
ai-tmpst Nov 7, 2024
14c2c32
access_log: Fix config handling
ai-tmpst Nov 7, 2024
5e44c1d
access_log: Move TfwBinLogFieldsLens inside function
ai-tmpst Nov 7, 2024
4735ab2
mmap_buffer, tfw_logger: Update comments
ai-tmpst Nov 7, 2024
c8b0fbc
mmap_buffer, tfw_logger: Annotate conditions with likely/unlikely
ai-tmpst Nov 8, 2024
38d91d9
tfw_logger: Add clickhouse building
ai-tmpst Nov 8, 2024
942f59e
mmap_buffer: Replaced NULL and IS_ERR checking by IS_ERR_OR_NULL
ai-tmpst Nov 9, 2024
2b0a7ff
mmap_buffer: Fix chrdev unregistering condition
ai-tmpst Nov 9, 2024
9911e60
tfw_logger: Delete block in the TfwClickhouse destructor
ai-tmpst Nov 9, 2024
d2db1bd
tfw_logger: Fix is_ready value at stopping
ai-tmpst Nov 9, 2024
c720f87
tfw_logger: Fix lines length in read_access_log_event()
ai-tmpst Nov 9, 2024
b655ba2
tfw_logger: Add separate error message for empty `host` argument
ai-tmpst Nov 9, 2024
93a922b
tfw_logger: Add logging to file using spdlog
ai-tmpst Nov 9, 2024
4c9af6e
tfw_logger: Add daemonization
ai-tmpst Nov 9, 2024
2ae35a7
tfw_logger: Add daemon stopping
ai-tmpst Nov 9, 2024
2700e13
tfw_logger: Add files that don't need to be tracked to .gitignore
ai-tmpst Nov 11, 2024
87a7fd6
mmap_buffer: Add a note about initializtion and freeing
ai-tmpst Nov 11, 2024
17492d7
tfw_logger: Replace block raw pointer by shared ptr
ai-tmpst Nov 11, 2024
0ce026d
tfw_logger: Add Clickhouse user/password support
ai-tmpst Nov 12, 2024
f86fc1b
tfw_logger: Close mmap buffer device even if an excpetion was raised
ai-tmpst Nov 12, 2024
122f3fa
tfw_logger: Rename *.h to *.hh to avoid checkpatch.pl errors
ai-tmpst Nov 12, 2024
f3d9167
tfw_logger: Remove deprecated boost header from error.hh
ai-tmpst Nov 12, 2024
332dbef
mmap_buffer: Fix dev_is_opened description
ai-tmpst Nov 12, 2024
0a8d53f
mmap_buffer: Remove unused variable and code from tfw_mmap_buffer_get…
ai-tmpst Nov 12, 2024
4d55631
tfw_logger: Add waiting for daemon process completion
ai-tmpst Nov 12, 2024
be04c3d
tfw_logger: Close all opened descriptors before daemonizing
ai-tmpst Nov 12, 2024
1365d01
tfw_logger: Add tfw_logger start/stop functionality to tempesta.sh
ai-tmpst Nov 13, 2024
60a1d5d
Merge branch 'master' into ai-537-2
ai-tmpst Nov 13, 2024
81fab3c
tfw_logger: Fix Makefile for multi-threaded building
ai-tmpst Nov 13, 2024
cab8cfe
tfw_logger: Fix logger creation
ai-tmpst Nov 13, 2024
5adb50c
tfw_logger: Flush logs on info messages
ai-tmpst Nov 14, 2024
3cd00ec
access_log: Don't recreate mmap_buffer on reloads
ai-tmpst Nov 14, 2024
049646e
tfw_logger: Replace get_buffer_size by init_buffer_size
ai-tmpst Nov 14, 2024
0bf6101
access_log: Make TfwBinLogFieldsLens static
ai-tmpst Nov 14, 2024
d4b4480
tfw_logger: Remove redundant std::move for std::string
ai-tmpst Nov 14, 2024
e1ff3ea
tfw_logger: Remove redundant return in callback function
ai-tmpst Nov 14, 2024
56bb7b4
tfw_logger: Create clickhouse::Block one time
ai-tmpst Nov 14, 2024
e7af517
tfw_logger: Move callee function befor caller in tempesta.sh
ai-tmpst Nov 14, 2024
d88af93
tfw_logger: Remove PID file at the end of daemonized process
ai-tmpst Nov 14, 2024
e6d1503
tfw_logger: Raise error if tfw_logger started unsuccessful
ai-tmpst Nov 14, 2024
27ee61e
tfw_logger: Check for logger PID file before daemon stopping
ai-tmpst Nov 14, 2024
8922ee8
tfw_logger: Get rid of incorrect std::move
ai-tmpst Nov 14, 2024
31db915
tfw_logger: Replace #ifdef/#define by #pragma once
ai-tmpst Nov 14, 2024
fe9b27d
tfw_logger: Fixed/added libraries connecting
ai-tmpst Nov 15, 2024
8cddeba
Add access_log description to etc/tempesta_fw.conf
ai-tmpst Nov 15, 2024
2a76e9c
tfw_logger: Redesign config parsing in tempesta.sh
ai-tmpst Nov 16, 2024
f0698df
tfw_logger: Fix members initialization in constructors
ai-tmpst Nov 16, 2024
813f5f1
tfw_logger: Annotate functions with noexcept
ai-tmpst Nov 16, 2024
743a290
tfw_logger: Send unsent data in ~TfwClickhouse()
ai-tmpst Nov 16, 2024
537a7cc
tfw_logger: Fix constants and time types
ai-tmpst Nov 17, 2024
23f8536
tfw_logger: Undefine INT_CASE macro
ai-tmpst Nov 17, 2024
f00a027
tfw_logger: Move length handling to INT_CASE macro
ai-tmpst Nov 17, 2024
bbbbf3a
tfw_logger: Raise exception for incorrect event length
ai-tmpst Nov 18, 2024
e6d322f
tfw_logger: Output debug dump to spdlog
ai-tmpst Nov 18, 2024
ec8e496
tfw_logger, access_log: Annotate conditions with unlikely macro
ai-tmpst Nov 18, 2024
097dac5
access_log: Fix incorrect event size calculation
ai-tmpst Nov 18, 2024
e43b44d
tfw_logger: Use std::packaged_task for asynchronous tasks execution
ai-tmpst Nov 18, 2024
87ceb9d
tfw_logger: Replace event field loop by sequential fields processing
ai-tmpst Nov 18, 2024
1e208ce
access_log: Replace T_WARN by T_DBG
ai-tmpst Nov 18, 2024
891f5e8
tfw_logger: Get rid of redundant check in callback
ai-tmpst Nov 18, 2024
a023de4
tfw_logger: Throw exception on affinity setting fail
ai-tmpst Nov 18, 2024
a9d7f80
tfw_logger: Remove unused Exception::print method
ai-tmpst Nov 18, 2024
91cd02c
Merge branch 'master' into ai-537-2
ai-tmpst Nov 18, 2024
78b3dbc
tfw_logger: Annotate arguments and class members with const qualifier
ai-tmpst Nov 19, 2024
b7fc6ad
tfw_logger: Add path to absl header files
ai-tmpst Nov 20, 2024
dc55314
tfw_logger: Add script to install dependencies
ai-tmpst Nov 20, 2024
f27888b
Fix incorrect allocation size.
EvgeniiMekhanik Nov 21, 2024
d8123e3
Correct handling exceptions
EvgeniiMekhanik Nov 22, 2024
a5a3419
tfw_logger: Make tempesta.sh handle all access_log tags
ai-tmpst Nov 21, 2024
aa00f53
Merge branch 'master' into ai-537-2
ai-tmpst Nov 26, 2024
c2f782c
tfw_logger: Check if daemon started successfully
ai-tmpst Nov 24, 2024
1fc2234
acces_log: Fix config handling for multiple access_log tags
ai-tmpst Nov 24, 2024
e29d6dd
tfw_logger: Move error message output to separate function
ai-tmpst Nov 24, 2024
536b782
tfw_logger: Do not try to execute tfw_logger on repeated start
ai-tmpst Nov 25, 2024
7d64837
tfw_logger: Remove TfwClickhouse destructor
ai-tmpst Nov 25, 2024
92fb5d6
tfw_logger: Fix fields order
ai-tmpst Nov 26, 2024
7158f76
tfw_logger: Reconnect to Clickhouse server after exceptions
ai-tmpst Nov 26, 2024
14d113b
tfw_logger: Create acces_log table in TfwClickhouse constructor
ai-tmpst Nov 26, 2024
7359b93
Break thread execution if `stop_flag` is set
EvgeniiMekhanik Nov 26, 2024
50465d7
tfw_logger: Fix incorrect variable handling in tempesta.sh
ai-tmpst Nov 27, 2024
8879200
Merge branch 'master' into ai-537-2
ai-tmpst Nov 28, 2024
90c885f
Revert "tfw_logger: Add script to install dependencies"
ai-tmpst Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 214 additions & 16 deletions fw/access_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include "connection.h"
#include "server.h"
#include "http.h"
#include "mmap_buffer.h"
#include "lib/common.h"
#include <linux/jiffies.h>

/* This thing describes access log format.
* - FIXED => fixed string, passed as is
Expand Down Expand Up @@ -58,11 +60,20 @@
TRUNCATABLE(user_agent) \
FIXED("\"")

static bool access_log_enabled = false;
#define ACCESS_LOG_OFF 0
#define ACCESS_LOG_DMESG 1
#define ACCESS_LOG_MMAP 2

#define MMAP_LOG_PATH "tempesta_mmap_log"

static int access_log_type = ACCESS_LOG_OFF;
static TfwMmapBufferHolder *mmap_buffer;

/* Use small buffer because printk won't display strings longer that ~1000 bytes */
#define ACCESS_LOG_BUF_SIZE 960
static DEFINE_PER_CPU_ALIGNED(char[ACCESS_LOG_BUF_SIZE], access_log_buf);
static DEFINE_PER_CPU_ALIGNED(u64, mmap_log_dropped);
static long mmap_log_buffer_size;

/** Build string consists of chunks that belong to the header value.
* If header value is empty, then it returns "-" to be nginx-like.
Expand Down Expand Up @@ -203,28 +214,28 @@ process_truncated(TfwStr *in, BasicStr *out, char *p, char *end,
unsigned total_len = 0;
unsigned truncated_count = 0;
unsigned max_untruncated_len, buf_avail;

if (unlikely(used_chars >= ACCESS_LOG_BUF_SIZE))
goto no_buffer_space;

/* Compute total length of all strings that can be truncated */
for (i = 0; i < TRUNCATABLE_FIELDS_COUNT; i++)
total_len += in[i].len;

/* Check if we're on happy path: all strings fit */
if (likely(total_len + used_chars < ACCESS_LOG_BUF_SIZE)) {
for (i = 0; i < TRUNCATABLE_FIELDS_COUNT; i++)
p = make_plain(p, end, in + i, out + i);
return;
}

/* Unhappy path: evenly distribute available buffer space across all
* strings that do not fit */
buf_avail = (ACCESS_LOG_BUF_SIZE - used_chars);
/* This division by constant usually gets optimized by compiler with
* multiplication/shifts */
max_untruncated_len = buf_avail / TRUNCATABLE_FIELDS_COUNT;

for (i = 0; i < TRUNCATABLE_FIELDS_COUNT; i++) {
/* we loose some chars due to string "less than", but
* tfw_str_to_cstr accounts terminating NUL to total buffer
Expand All @@ -234,7 +245,7 @@ process_truncated(TfwStr *in, BasicStr *out, char *p, char *end,
else
truncated_count++;
}

max_untruncated_len = buf_avail / truncated_count;
if (max_untruncated_len < sizeof("..."))
goto no_buffer_space;
Expand Down Expand Up @@ -266,6 +277,123 @@ process_truncated(TfwStr *in, BasicStr *out, char *p, char *end,
}
}

static void
do_access_log_req_mmap(TfwHttpReq *req, u16 resp_status,
u32 resp_content_length)
{
u64 *dropped = this_cpu_ptr(&mmap_log_dropped);
TfwBinLogEvent *event;
unsigned int room_size;
TfwStr referer, ua;
u32 resp_time;
char *data, *p;

if (!mmap_buffer)
EvgeniiMekhanik marked this conversation as resolved.
Show resolved Hide resolved
goto drop;

room_size = tfw_mmap_buffer_get_room(mmap_buffer, &data);
if (room_size < sizeof(TfwBinLogEvent))
goto drop;

event = (TfwBinLogEvent *)data;
p = data + sizeof(TfwBinLogEvent);

#define WRITE_TO_BUF(val, size) \
do { \
if (room_size < size) \
goto drop; \
memcpy_fast(p, val, size); \
p += size; \
room_size -= size; \
} while (0)

#define WRITE_FIELD(field, val) \
do { \
if (TFW_MMAP_LOG_FIELD_IS_SET(event, TFW_MMAP_LOG_##field)) { \
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
WRITE_TO_BUF(&val, sizeof(val)); \
} \
} while (0)

event->timestamp = jiffies;

if (*dropped && room_size >= sizeof(u64)) {
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
event->type = TFW_MMAP_LOG_TYPE_DROPPED;

memcpy_fast(p, dropped, sizeof(u64));
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
tfw_mmap_buffer_commit(mmap_buffer, p - data);
EvgeniiMekhanik marked this conversation as resolved.
Show resolved Hide resolved

*dropped = 0;
room_size = tfw_mmap_buffer_get_room(mmap_buffer, &data);
p = data + sizeof(TfwBinLogEvent);
event = (TfwBinLogEvent *)data;
}

event->type = TFW_MMAP_LOG_TYPE_ACCESS;
event->fields = TFW_MMAP_LOG_ALL_FIELDS_MASK; /* Enable all the fields */

WRITE_FIELD(ADDR, req->conn->peer->addr.sin6_addr);
WRITE_FIELD(METHOD, req->method);
WRITE_FIELD(VERSION, req->version);
WRITE_FIELD(STATUS, resp_status);
WRITE_FIELD(RESP_CONT_LEN, resp_content_length);
resp_time = jiffies - req->jrxtstamp;
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
WRITE_FIELD(RESP_TIME, resp_time);

#define ACCES_LOG_MAX_STR_LEN 65535UL
#define WRITE_STR_FIELD(field, val) \
do { \
if (TFW_MMAP_LOG_FIELD_IS_SET(event, TFW_MMAP_LOG_##field)) { \
TfwStr *c, *end; \
u16 len = (u16)min((val).len, ACCES_LOG_MAX_STR_LEN); \
WRITE_TO_BUF(&len, 2); \
TFW_STR_FOR_EACH_CHUNK(c, &val, end) { \
u16 cur_len = (u16)min((unsigned long)len, \
c->len); \
WRITE_TO_BUF(c->data, cur_len); \
len -= cur_len; \
} \
} \
} while (0)

if (TFW_MMAP_LOG_FIELD_IS_SET(event, TFW_MMAP_LOG_VHOST)) {
u16 len = 0;

if (req->vhost && req->vhost->name.len) {
len = (u16)min(req->vhost->name.len,
ACCES_LOG_MAX_STR_LEN);
WRITE_TO_BUF(&len, 2);
WRITE_TO_BUF(req->vhost->name.data, len);
} else {
WRITE_TO_BUF(&len, 2);
}
}

WRITE_STR_FIELD(URI, req->uri_path);

referer = get_http_header_value(req->version,
req->h_tbl->tbl + TFW_HTTP_HDR_REFERER);
WRITE_STR_FIELD(REFERER, referer);

ua = get_http_header_value(req->version,
req->h_tbl->tbl + TFW_HTTP_HDR_USER_AGENT);
WRITE_STR_FIELD(USER_AGENT, ua);

if (tfw_mmap_buffer_commit(mmap_buffer, p - data) != 0) {
T_WARN("Incorrect data size at commit: %ld", p - data);
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
goto drop;
}

return;

drop:
++*dropped;

#undef WRITE_STR_FIELD
#undef ACCES_LOG_MAX_STR_LEN
#undef WRITE_FIELD
#undef WRITE_TO_BUF
}

void
do_access_log_req(TfwHttpReq *req, int resp_status, unsigned long resp_content_length)
{
Expand All @@ -279,10 +407,12 @@ do_access_log_req(TfwHttpReq *req, int resp_status, unsigned long resp_content_l
TfwStr truncated_in[TRUNCATABLE_FIELDS_COUNT];
BasicStr truncated_out[TRUNCATABLE_FIELDS_COUNT];

/* Check if logging is enabled */
if (!access_log_enabled)
if (access_log_type & ACCESS_LOG_MMAP)
do_access_log_req_mmap(req, (u16)resp_status, (u32)resp_content_length);

if (!(access_log_type & ACCESS_LOG_DMESG))
return;
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved

/* client_ip
*
* this BUG_ON would only trigger if
Expand Down Expand Up @@ -327,7 +457,7 @@ do_access_log_req(TfwHttpReq *req, int resp_status, unsigned long resp_content_l
} else {
version = missing;
}

/* status, content_length */
/* NOTE: we only roughly estimate lengths of numbers, leaving final
* transformation to printk. This has some side-effects like string
Expand All @@ -341,15 +471,15 @@ do_access_log_req(TfwHttpReq *req, int resp_status, unsigned long resp_content_l
status.len = 10; /* len(str(2**32)) */
content_length.data = "";
content_length.len = 20; /* len(str(2**64)) */

/* Process truncated fields */
truncated_in[idx_uri] = req->uri_path;
#define ADD_HDR(id, tfw_hdr_id) \
truncated_in[id] = get_http_header_value(req->version, \
req->h_tbl->tbl + tfw_hdr_id);
ADD_HDR(idx_referer, TFW_HTTP_HDR_REFERER);
ADD_HDR(idx_user_agent, TFW_HTTP_HDR_USER_AGENT);

/* Now we calculate first estimation of
* "maximum allowed truncated string length" */
#define ESTIMATE_FIXED(str) + (sizeof(str) - 1)
Expand Down Expand Up @@ -413,21 +543,89 @@ do_access_log(TfwHttpResp *resp)
TFW_HTTP_RESP_CUT_BODY_SZ(resp));
}

static int
cfg_access_log_set(TfwCfgSpec *cs, TfwCfgEntry *ce)
{
int i;
const char *val;

TFW_CFG_CHECK_VAL_N(>, 0, cs, ce);
TFW_CFG_CHECK_NO_ATTRS(cs, ce);
EvgeniiMekhanik marked this conversation as resolved.
Show resolved Hide resolved

access_log_type = ACCESS_LOG_OFF;

TFW_CFG_ENTRY_FOR_EACH_VAL(ce, i, val) {
if (strcasecmp(val, "off") == 0)
EvgeniiMekhanik marked this conversation as resolved.
Show resolved Hide resolved
break;

if (strcasecmp(val, "dmesg") == 0) {
access_log_type |= ACCESS_LOG_DMESG;
} else if (strcasecmp(val, "mmap") == 0) {
access_log_type |= ACCESS_LOG_MMAP;
} else {
T_ERR_NL("invalid access_log value: '%s'\n", val);
return -EINVAL;
}
}

return 0;
}

static int
tfw_access_log_start(void)
{
int cpu;

if (!(access_log_type & ACCESS_LOG_MMAP))
return 0;

if (mmap_buffer)
EvgeniiMekhanik marked this conversation as resolved.
Show resolved Hide resolved
tfw_mmap_buffer_free(mmap_buffer);

mmap_buffer = tfw_mmap_buffer_create(MMAP_LOG_PATH, mmap_log_buffer_size);

for_each_online_cpu(cpu) {
u64 *dropped = per_cpu_ptr(&mmap_log_dropped, cpu);
*dropped = 0;
}

return mmap_buffer ? 0 : -EINVAL;
}

static void
tfw_access_log_stop(void)
{
tfw_mmap_buffer_free(mmap_buffer);
mmap_buffer = NULL;
}

static TfwCfgSpec tfw_http_specs[] = {
{
.name = "access_log",
.deflt = "off",
.handler = tfw_cfg_set_bool,
.dest = &access_log_enabled,
.deflt = NULL,
.handler = cfg_access_log_set,
.allow_none = true,
.allow_repeat = true,
},
{
.name = "mmap_log_buffer_size",
.deflt = "1M",
.handler = tfw_cfg_set_mem,
.dest = &mmap_log_buffer_size,
.spec_ext = &(TfwCfgSpecMem) {
.multiple_of = "4K",
.range = { TFW_MMAP_BUFFER_MIN_SIZE_STR,
TFW_MMAP_BUFFER_MAX_SIZE_STR },
}
},
krizhanovsky marked this conversation as resolved.
Show resolved Hide resolved
{ 0 }
};

TfwMod tfw_access_log_mod = {
.name = "access_log",
.specs = tfw_http_specs,
.start = tfw_access_log_start,
.stop = tfw_access_log_stop,
};

/*
Expand Down
Loading