summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/uhttpd/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-03-18 20:10:13 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-03-18 20:10:13 +0000
commit3403abe05fc62efda046fe65c0b43ce785ab1f4d (patch)
treec96704ae3ec5f2c7d382f090d89c2d3ac13263a2 /contrib/package/uhttpd/src
parent87329b4522760f0a4a9a7962a52faf76d2db6f55 (diff)
uhttpd: only enable Lua runtime if a handler was specified
Diffstat (limited to 'contrib/package/uhttpd/src')
-rw-r--r--contrib/package/uhttpd/src/uhttpd.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/contrib/package/uhttpd/src/uhttpd.c b/contrib/package/uhttpd/src/uhttpd.c
index ffa44aacc7..1f66f785f0 100644
--- a/contrib/package/uhttpd/src/uhttpd.c
+++ b/contrib/package/uhttpd/src/uhttpd.c
@@ -347,8 +347,8 @@ static int uh_docroot_resolve(const char *path, char *buf)
int main (int argc, char **argv)
{
#ifdef HAVE_LUA
- /* init Lua runtime */
- lua_State *L;
+ /* Lua runtime */
+ lua_State *L = NULL;
#endif
/* master file descriptor list */
@@ -552,15 +552,6 @@ int main (int argc, char **argv)
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
/* default cgi prefix */
if( ! conf.cgi_prefix )
@@ -568,8 +559,15 @@ int main (int argc, char **argv)
#endif
#ifdef HAVE_LUA
- /* init Lua runtime */
- L = uh_lua_init(conf.lua_handler);
+ /* init Lua runtime if handler is specified */
+ if( conf.lua_handler )
+ {
+ /* default lua prefix */
+ if( ! conf.lua_prefix )
+ conf.lua_prefix = "/lua";
+
+ L = uh_lua_init(conf.lua_handler);
+ }
#endif
/* fork (if not disabled) */
@@ -682,8 +680,9 @@ int main (int argc, char **argv)
#endif
#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);
}
else
@@ -715,7 +714,8 @@ int main (int argc, char **argv)
#ifdef HAVE_LUA
/* destroy the Lua state */
- lua_close(L);
+ if( L != NULL )
+ lua_close(L);
#endif
return 0;