lua-users home
lua-l archive

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


Hi Diego:

I like very much the setfd method added in 2.0, but...

Let me show the following scenery:
two Lua States ( L1 and L2) in two different OS threads.

thread 1:
while true  do
        local skt = sskt:accept( )
        local fd = skt:getfd( )
        SendTheFileDescriptorToThread2( fd)
        skt:close( )
end

thread 2:
while true do
         local fd = ReceiveTheFileDescriptorFromThread1( )
         local skt = socket.tcp( )
         skt:setfd( fd) -- *
         ... -- something to do
end

The fd at * is dead after the skt:close of the first thread.
Also, at * we are "replacing" the fd in the socket object, without freeing
it, that is, wasting OS resources.

First problem can be worked around setting the fd to INVALID_SOCKET before
skt:close( ).
But for the second problem, I suggest to add a socket_destroy ( in tcp.c )
on the current OS fd before setting the new one.

Despite this multithreading problem, I like the new structure of the library
and I am planning to integrate support for IBM WebSphere MQ ( formerly
MQSeries).

Thanks,
Daniel

----- Original Message -----
From: <diego@tecgraf.puc-rio.br>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Friday, June 18, 2004 6:36 PM
Subject: [ANNOUNCE]: LuaSocket 2.0 beta


> Hi all,
>
> I am glad to finally release LuaSocket 2.0 beta:
>  ...