Skip to content

Commit c317fee

Browse files
committed
optimize: save our own log ctx for timers.
1 parent c6930f0 commit c317fee

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/ngx_http_lua_timer.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ typedef struct {
3737
} ngx_http_lua_timer_ctx_t;
3838

3939

40-
typedef struct {
41-
ngx_connection_t *connection;
42-
} ngx_http_lua_timer_log_ctx_t;
43-
44-
4540
static int ngx_http_lua_ngx_timer_at(lua_State *L);
4641
static void ngx_http_lua_timer_handler(ngx_event_t *ev);
4742
static u_char * ngx_http_lua_log_timer_error(ngx_log_t *log, u_char *buf,
@@ -306,7 +301,6 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
306301
ngx_http_lua_timer_ctx_t tctx;
307302
ngx_http_lua_main_conf_t *lmcf;
308303
ngx_http_core_loc_conf_t *clcf;
309-
ngx_http_lua_timer_log_ctx_t *logctx;
310304

311305
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
312306
"lua ngx.timer expired");
@@ -331,15 +325,8 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
331325
goto failed;
332326
}
333327

334-
logctx = ngx_palloc(c->pool, sizeof(ngx_http_lua_timer_log_ctx_t));
335-
if (logctx == NULL) {
336-
goto failed;
337-
}
338-
339-
logctx->connection = c;
340-
341328
c->log->handler = ngx_http_lua_log_timer_error;
342-
c->log->data = logctx;
329+
c->log->data = c;
343330

344331
c->listening = tctx.listening;
345332
c->addr_text = tctx.client_addr_text;
@@ -476,24 +463,20 @@ ngx_http_lua_log_timer_error(ngx_log_t *log, u_char *buf, size_t len)
476463
u_char *p;
477464
ngx_connection_t *c;
478465

479-
ngx_http_lua_timer_log_ctx_t *ctx;
480-
481466
if (log->action) {
482467
p = ngx_snprintf(buf, len, " while %s", log->action);
483468
len -= p - buf;
484469
buf = p;
485470
}
486471

487-
ctx = log->data;
472+
c = log->data;
488473

489474
dd("ctx = %p", ctx);
490475

491476
p = ngx_snprintf(buf, len, ", context: ngx.timer");
492477
len -= p - buf;
493478
buf = p;
494479

495-
c = ctx->connection;
496-
497480
if (c->addr_text.len) {
498481
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
499482
len -= p - buf;

0 commit comments

Comments
 (0)