Skip to content

Commit ff81634

Browse files
syzhdoujiang24
authored andcommitted
optimize: added the "ev" to ngx_posted_delayed_events instead of the rbtree for 0 delay timer,
so that we can save an epoll wait in such case.
1 parent df4033d commit ff81634

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/ngx_http_lua_timer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ ngx_http_lua_ngx_timer_helper(lua_State *L, int every)
328328

329329
lmcf->pending_timers++;
330330

331+
#ifdef HAVE_POSTED_DELAYED_EVENTS_PATCH
332+
if (delay == 0) {
333+
dd("posting 0 sec sleep event to head of delayed queue");
334+
ngx_post_event(ev, &ngx_posted_delayed_events);
335+
336+
lua_pushinteger(L, 1);
337+
return 1;
338+
}
339+
#endif
340+
331341
ngx_add_timer(ev, delay);
332342

333343
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,

0 commit comments

Comments
 (0)