summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-04-18 18:31:04 +0800
committerZhidao HONG <z.hong@f5.com>2024-08-20 09:17:23 +0800
commitecb3f86c8528a26d770e93bd5296b780981e20ff (patch)
tree2c3c764d079cd576aee2aa51bf8f9d2faea91ee1 /src
parent9d19e7e0ff5cfd75644df9fcf91c37db25aa7109 (diff)
downloadunit-ecb3f86c8528a26d770e93bd5296b780981e20ff.tar.gz
unit-ecb3f86c8528a26d770e93bd5296b780981e20ff.tar.bz2
http: Refactor access log write
Diffstat (limited to 'src')
-rw-r--r--src/nxt_router_access_log.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/nxt_router_access_log.c b/src/nxt_router_access_log.c
index ff17b0b6..cc8d5e4f 100644
--- a/src/nxt_router_access_log.c
+++ b/src/nxt_router_access_log.c
@@ -26,10 +26,8 @@ typedef struct {
static void nxt_router_access_log_writer(nxt_task_t *task,
nxt_http_request_t *r, nxt_router_access_log_t *access_log,
nxt_tstr_t *format);
-static void nxt_router_access_log_write_ready(nxt_task_t *task, void *obj,
- void *data);
-static void nxt_router_access_log_write_error(nxt_task_t *task, void *obj,
- void *data);
+static void nxt_router_access_log_write(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_router_access_log_ctx_t *ctx);
static void nxt_router_access_log_ready(nxt_task_t *task,
nxt_port_recv_msg_t *msg, void *data);
static void nxt_router_access_log_error(nxt_task_t *task,
@@ -180,8 +178,6 @@ nxt_router_access_log_writer(nxt_task_t *task, nxt_http_request_t *r,
if (nxt_tstr_is_const(format)) {
nxt_tstr_str(format, &ctx->text);
- nxt_router_access_log_write_ready(task, r, ctx);
-
} else {
rtcf = r->conf->socket_conf->router_conf;
@@ -191,36 +187,26 @@ nxt_router_access_log_writer(nxt_task_t *task, nxt_http_request_t *r,
return;
}
- nxt_tstr_query(task, r->tstr_query, format, &ctx->text);
- nxt_tstr_query_resolve(task, r->tstr_query, ctx,
- nxt_router_access_log_write_ready,
- nxt_router_access_log_write_error);
- }
+ ret = nxt_tstr_query(task, r->tstr_query, format, &ctx->text);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return;
+ }
+ }
+
+ nxt_router_access_log_write(task, r, ctx);
}
static void
-nxt_router_access_log_write_ready(nxt_task_t *task, void *obj, void *data)
+nxt_router_access_log_write(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_router_access_log_ctx_t *ctx)
{
- nxt_http_request_t *r;
- nxt_router_access_log_ctx_t *ctx;
-
- r = obj;
- ctx = data;
-
nxt_fd_write(ctx->access_log->fd, ctx->text.start, ctx->text.length);
nxt_http_request_close_handler(task, r, r->proto.any);
}
-static void
-nxt_router_access_log_write_error(nxt_task_t *task, void *obj, void *data)
-{
-
-}
-
-
void
nxt_router_access_log_open(nxt_task_t *task, nxt_router_temp_conf_t *tmcf)
{