On Wednesday 13, Alexander Gladysh wrote: > On Thu, Apr 14, 2011 at 06:07, Fabio Mascarenhas <mascaren...@acm.org> wrote: > > On Wed, Apr 13, 2011 at 5:11 PM, Alexander Gladysh <aglad...@gmail.com> > > wrote: > > > > I think we are talking past each other. > > Perhaps. Sorry if that is the case. > > > What I am trying to say is > > that I do not see a way to add the features you need to every WSAPI > > connector without dragging several other dependencies, and event > > handling/threading/async is currently very messy in Lua. But adding > > the capability to do what you want is not difficult if you are willing > > to bite the bullet and include the necessary dependencies: > > > > https://gist.github.com/918768 > > > > This uses Robert's threading library and 0MQ binding, so will also > > work with LuaJIT. Farm blocking stuff to the helper threads that send > > messages to the application when they have stuff for the app to do. > > The application checks its inbox whenever it is idle. > > I will consider this carefully. > > One extra thread per fork upsets me deeply (maybe it should not).
That accept thread would only really add a bit of memory overhead. So unless you are forking many thousands of fastcgi process, I don't see it as an issue. The cpu overhead would be minimal since those threads would be sleeping most of the time. Also the round-trip latency for each lfcgi.accept() should be less then about 20-30 microseconds. > Do not read this as critique, but I think that it is a sign that I > should not use WSAPI anymore (my problem, not WSAPI problem). Sadly I > have too much legacy code to afford a switch now, so I guess I have to > find some compromise for a while... You could use a WSAPI wrapper similar to Fabio's and instead of calling lfcgi.accept() in a sub-thread, you can use select() on fd 0 (See FCGI_LISTENSOCK_FILENO from fastcgi.h [1]) and a command socket. When fd 0 becomes readable you call lfcgi.accept to handle the incoming request. If the command socket is readable, then you read a message from the command socket. I would only recommend that for your existing WSAPI applications that you don't want to port to a better solution. 1. http://code.google.com/p/lfcgi/source/browse/trunk/libfcgi-2.4.0/include/fastcgi.h -- Robert G. Jakabosky _______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/
