lua-nginx-module
lua-nginx-module copied to clipboard
New Feature: added args support for ngx.on_abort
In typical Lua usage, one would just pass a closure to on_abort rather than using pass values:
ngx.on_abort(function() someotherfunction(my, arguments, for, the, other, function) end )
Because we need keep consistent with ngx.timer.at API.
@bakins Creating new closures at every request does introduce some overhead (observable in on-CPU time Flame Graphs, for example), so I think we need the ability to pass user arguments just as in ngx.timer.at().
@agentzh I'm not surprised by the creation of a closure on each request showing up in a flame graph, I just wonder how much difference it makes in the real world. I don't have any strong feelings either way other than using a closure is more "Lua like."
@bakins Creating closures per request could be a real bottleneck, as observed as 20% ~ 30% overall overhead in an on-CPU time flame graph for our Lua WAF system. Even though in that case it was not ngx.on_abort() in particular, but more aggressive use of "higher-order functions".
This pull request is now in conflict :(