lua-users home
lua-l archive

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

Hi guys,

I have a talker server, written mostly in Lua 4, which uses LuaSocket
for doing its socketing chores.

It occasionally suffers bizarre problems.  This is normally shown by one
person saying something, and then another person saying exactly the same
thing straight away, as if they'd typed it (although they hadn't.)

I'm fairly sure, due to the way the talker works, that it isn't my
code.  It also occurred to me recently that the problem only started
occurring after I wrote a "fudge" to make the talker a little quicker.

The talker requires to know the time all over the place; for working out
when somebody last said something (for the purpose of disconnecting them
if they're idle etc) and several other things.  Before, I just called
time() whenever it needed to know.  It ended up making a lot of
syscalls, making up the majority of the talker's CPU usage.  So I wrote
a little Lua binding to some C that works by setting up an alarm() once
a second, and in the signal handler, updating an internal value with the
current time.  Then, the Lua side just calls a C function to fetch this
value.  It's much much quicker.  (It halved the talker's CPU usage over
a day.)

This makes me wonder if LuaSocket doesn't play well when signals are
thrown into the mix.  Has anybody else had similar issues with
LuaSocket?  I'm told there's a whole world of pain when you start mixing
signals and select() - are there any plans to let LuaSocket use poll()
in any newer versions?  (Even if they're only for Lua 5)

Thanks for any help,
Rob Kendrick, Pepperfish Limited         
PGP signed or encrypted mail welcome                         Key ID: 3651D17A