lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

First I have found what looks like a bug to me, which surprises
me a lot:

There was an error in the specified application. The full error message follows:

/usr/local/share/lua/5.1//wsapi/common.lua:393: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
	[C]: in function 'ipairs'
	/usr/local/share/lua/5.1//wsapi/common.lua:393: in function 'collect_states'
	/usr/local/share/lua/5.1//wsapi/common.lua:442: in function 
	(tail call): ?
	[C]: in function 'xpcall'
	/usr/local/share/lua/5.1//wsapi/common.lua:195: in function 'run_app'
	/usr/local/share/lua/5.1//wsapi/common.lua:219: in function 'run'
	/usr/local/share/lua/5.1//wsapi/fastcgi.lua:38: in function 'run'
	/var/www/test.netpim.info/cgi/netpim.fcgi:24: in main chunk
	[C]: ?

I have installed WSAPI with fastcgi and apache's mod_fcgi.
The way it works is that I run a first request, it works well and all.
Then I wait a while (longer than the period defined in wsapi.fcgi runner script)
and I get this error.

I have tracked it in wsapi.common and it looks to me that app_states[app].states
is never initialized to be a table.
The init code seems to be at line 370 in the metamethod __index. But the code is:
  setmetatable(app_states, { __index = function (tab, app)
                                          tab[app] = {}
                                          return tab[app]
                                       end })

Shouldn't it be more like:
  setmetatable(app_states, { __index = function (tab, app)
                                          tab[app] = { states={} }
                                          return tab[app]
                                       end })

I have fixed it this way in my version and it seems to work all fine.

Secondly I am having an other problem, in my setup with apache and fcgi
let's say I make an app for the url /lua/foo.ws
It works fine and my app is called.
Now if I try to access it as /lua/foo.ws/whatever, if I am reading things right it
should still work (otherwise Orbit dispatchers becomes quite useless no ?)
But it does not, I get an error that wsapi does not find the app to launch.
/usr/local/share/lua/5.1//wsapi/common.lua:315: could not find a filename to load, check your configuration or URL
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1//wsapi/common.lua:315: in function 'adjust_non_wrapped'
	/usr/local/share/lua/5.1//wsapi/common.lua:324: in function 'normalize_paths'
	/usr/local/share/lua/5.1//wsapi/common.lua:340: in function 'find_module'
	/usr/local/share/lua/5.1//wsapi/common.lua:406: in function 
	(tail call): ?
	(tail call): ?
	[C]: in function 'xpcall'
	/usr/local/share/lua/5.1//wsapi/common.lua:195: in function 'run_app'
	/usr/local/share/lua/5.1//wsapi/common.lua:219: in function 'run'
	/usr/local/share/lua/5.1//wsapi/fastcgi.lua:38: in function 'run'
	/var/www/test.netpim.info/cgi/netpim.fcgi:24: in main chunk
	[C]: ?

The problem is that in normalize_paths() in wsapi.common there are three lines:
   if not filename or filename == "" then
      filename = wsapi_env.PATH_TRANSLATED
      if filename == "" then filename = wsapi_env.SCRIPT_FILENAME end

"filename" parameter comes from the wsapi.fcgi launcher which sets it as ""
thus the code enters the if and replaced filename with PATH_TRANSLATED which
does not contain the app name.
In my example (/lua/foo.ws/whatever) I have:
PATH_TRANSLATED=/var/www/test.netpim.info/htdocs/whatever
SCRIPT_FILENAME=/var/www/test.netpim.info/htdocs/lua/foo.ws

I resolved my problem by forcing "filename = wsapi_env.SCRIPT_FILENAME" but
it looks like a bad fix to me.
Any ideas ?

Thanks