Hello!
On Wed, Oct 10, 2012 at 11:25 AM, Antoine wrote:
> In the HTTPLuaModule (http://wiki.nginx.org/HttpLuaModule#ngx.exit) it
> is said that "it is strongly recommended to combine the return statement
> with this call, i.e., return ngx.exit(...)."
>
Sorry for the confusion in the docs, I've tweaked it a bit:
http://wiki.nginx.org/HttpLuaModule#ngx.exit
And that sentence now reads:
"It is recommended, though not necessary, to combine the return
statement with this call, i.e., return ngx.exit(...), to give a visual
hint to others reading the code."
> Would it be possible to have a reason for this recommandation
Just for code readability, no functional differences.
> and to
> have a small example to understand to what extent using
> return/exit(ngx.CODE) differently is risky ?
No, it's not be risky if return is absent. ngx.exit() uses
coroutine.yield() behind the scene, so the current execution flow will
be interrupted anyhow.
> For instance, if there is no lua function in a lua file called by
> content_by_lua_file '...', is the "return" needed or not ?
>
According to the current implementation, empty Lua code chunks
specified in content/rewrite/access/etc_by_lua is not allowed. So you
need to at least put a "return" there ;)
I'd remove this empty code chunk check in a future release of ngx_lua.
But it's not of priority at the moment :)
Thanks!
-agentzh