Skip to content

Commit 248060b

Browse files
spacewanderthibaultcha
authored andcommitted
feature: errors are now logged when timers fail to run.
Signed-off-by: Thibault Charbonnier <[email protected]>
1 parent 7c2b58e commit 248060b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/ngx_http_lua_timer.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ ngx_http_lua_ngx_timer_helper(lua_State *L, int every)
350350

351351
ngx_add_timer(ev, delay);
352352

353+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
354+
"created timer (co: %p delay: %M ms)", tctx->co, delay);
355+
353356
lua_pushinteger(L, 1);
354357
return 1;
355358

@@ -509,6 +512,10 @@ ngx_http_lua_timer_copy(ngx_http_lua_timer_ctx_t *old_tctx)
509512

510513
ngx_add_timer(ev, tctx->delay);
511514

515+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
516+
"created next timer (co: %p delay: %M ms)", tctx->co,
517+
tctx->delay);
518+
512519
return NGX_OK;
513520

514521
nomem:
@@ -580,6 +587,9 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
580587

581588
c = ngx_http_lua_create_fake_connection(tctx.pool);
582589
if (c == NULL) {
590+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
591+
"failed to create fake connection to run timer (co: %p)",
592+
tctx.co);
583593
goto failed;
584594
}
585595

@@ -591,6 +601,9 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
591601

592602
r = ngx_http_lua_create_fake_request(c);
593603
if (r == NULL) {
604+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
605+
"failed to create fake request to run timer (co: %p)",
606+
tctx.co);
594607
goto failed;
595608
}
596609

@@ -626,6 +639,8 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
626639

627640
ctx = ngx_http_lua_create_ctx(r);
628641
if (ctx == NULL) {
642+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
643+
"failed to create ctx to run timer (co: %p)", tctx.co);
629644
goto failed;
630645
}
631646

@@ -634,6 +649,9 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
634649

635650
pcln = ngx_pool_cleanup_add(r->pool, 0);
636651
if (pcln == NULL) {
652+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
653+
"failed to add vm cleanup to run timer (co: %p)",
654+
tctx.co);
637655
goto failed;
638656
}
639657

@@ -647,6 +665,9 @@ ngx_http_lua_timer_handler(ngx_event_t *ev)
647665

648666
cln = ngx_http_cleanup_add(r, 0);
649667
if (cln == NULL) {
668+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
669+
"failed to add request cleanup to run timer (co: %p)",
670+
tctx.co);
650671
goto failed;
651672
}
652673

0 commit comments

Comments
 (0)