uhttpd: only enable Lua runtime if a handler was specified
This commit is contained in:
parent
87329b4522
commit
3403abe05f
1 changed files with 16 additions and 16 deletions
|
@ -347,8 +347,8 @@ static int uh_docroot_resolve(const char *path, char *buf)
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
/* init Lua runtime */
|
/* Lua runtime */
|
||||||
lua_State *L;
|
lua_State *L = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* master file descriptor list */
|
/* master file descriptor list */
|
||||||
|
@ -552,15 +552,6 @@ int main (int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LUA
|
|
||||||
/* default lua prefix and handler */
|
|
||||||
if( ! conf.lua_handler )
|
|
||||||
conf.lua_handler = "./lua/handler.lua";
|
|
||||||
|
|
||||||
if( ! conf.lua_prefix )
|
|
||||||
conf.lua_prefix = "/lua";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CGI
|
#ifdef HAVE_CGI
|
||||||
/* default cgi prefix */
|
/* default cgi prefix */
|
||||||
if( ! conf.cgi_prefix )
|
if( ! conf.cgi_prefix )
|
||||||
|
@ -568,8 +559,15 @@ int main (int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
/* init Lua runtime */
|
/* init Lua runtime if handler is specified */
|
||||||
L = uh_lua_init(conf.lua_handler);
|
if( conf.lua_handler )
|
||||||
|
{
|
||||||
|
/* default lua prefix */
|
||||||
|
if( ! conf.lua_prefix )
|
||||||
|
conf.lua_prefix = "/lua";
|
||||||
|
|
||||||
|
L = uh_lua_init(conf.lua_handler);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* fork (if not disabled) */
|
/* fork (if not disabled) */
|
||||||
|
@ -682,8 +680,9 @@ int main (int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
if( strstr(req->url, conf.lua_prefix) == req->url )
|
if( (L != NULL) &&
|
||||||
{
|
(strstr(req->url, conf.lua_prefix) == req->url)
|
||||||
|
) {
|
||||||
uh_lua_request(cl, req, L);
|
uh_lua_request(cl, req, L);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -715,7 +714,8 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
/* destroy the Lua state */
|
/* destroy the Lua state */
|
||||||
lua_close(L);
|
if( L != NULL )
|
||||||
|
lua_close(L);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue