Bugs in Lua binding

76 views
Skip to first unread message

bel

unread,
Sep 29, 2013, 5:31:09 PM9/29/13
to cive...@googlegroups.com
There are some bugs in the LSP binding:

1) it does not work if keep_alive is enabled. A quick fix would be to add
conn->must_close=1;
somewhere in handle_lsp_request.

2) the lsqlite3 lib is for Lua 5.1 (dated 2007), but there is a newer one that supports 5.2 (dated 2013)

While for 5.1, library functions were registered by
luaL_register(L, "sqlite3", sqlitelib);

For 5.2 one should use (for an equivalent functionality)
luaL_requiref(L, "sqlite3", luaopen_sqlitelib, 1);

static int luaopen_sqlitelib (lua_State *L) {
    luaL_newlibtable(L, sqlitelib);
    luaL_setfuncs(L, sqlitelib, 0);
    return 1;
}

3) In some cases, the execution of the Lua script stops somewhere, e.g., if you add mg.write(tostring(sqlite3)) which should either print "table: XXXXXXXX" or "nil",
instead the script stops without any error indication. I don't know what causes this behavior yet.
 

bel

unread,
Oct 2, 2013, 5:30:29 PM10/2/13
to cive...@googlegroups.com
I guess Lua support was not really built for Windows (Visual Studio) with the sources within the civetweb-1.4.tar.gz from http://sourceforge.net/projects/civetweb/files/1.4/ ?

In order to build it, I had to add the defines USE_LUA;USE_WEBSOCKET;USE_LUA_SQLITE3 and set the include path to
$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)

A current lsqlite3.c version (2013) compatible with Lua 5.2 is attached. It should completely replace the one currently in the source tree from 2007.
There has been an interface change in civetweb.c for "conn2", the corresponding update in mod_lua.inl was still missing. The must_close has been added (one could improve this in a next step).
The two files attached do work in my test.



mod_lua.inl
lsqlite3.c
Reply all
Reply to author
Forward
0 new messages