lua-users home
lua-l archive

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


First of all, I appriciate all guys of Lua team. Interesting language.

I have a bit trouble with lua thread. I made a small sample code of 
just getting some web pages with luathread and luasocket. And it does
not work. Give me any help.

I guess there would be three possible cause.

a, My complie/install of luathread/luasocket is wrong.
   If so, tell me something from ldd output.
b. luasocket does not work under multi threading.
c. just my sample code is wrong.

Note: Two samples ( Parent-child and Producer-consumer from Diego's site)
      works well.

               --- Okajima, Jun. Tokyo, Japan.

okajima@Debian:~$ lua.thread http.sample.lua
start   2

( this must be like

   start 2
   start 3
   start 1
   start 4 1 48712
  , but lua terminated just after starting thread 2.
okajima@Debian:~$ cat http.sample.lua
function get(str, n)
    local http = require("socket.http")
    local out,len
    print("start", n)
    out = http.request(str)
    len = string.len(out)
    print(str, n, len)

thread.newthread(get,{"";, 1})
thread.newthread(get,{"";, 2})
thread.newthread(get,{"";, 3})
thread.newthread(get,{"";, 4})

os.execute("sleep 10")
okajima@Debian:~$ ls -la /home/okajima/bin/lua.thread
-rwxr-xr-x  1 okajima okajima 171609 Aug 15 22:03 /home/okajima/bin/lua.thread
okajima@Debian:~$ ldd /home/okajima/bin/lua.thread => /lib/tls/ (0xb7fc4000) => /lib/tls/ (0xb7fb4000) => /lib/ (0xb7f87000) => /lib/ (0xb7f80000) => /lib/ (0xb7f3e000) => /lib/tls/ (0xb7f3b000) => /lib/tls/ (0xb7e06000)
        /lib/ => /lib/ (0xb7fea000)
okajima@Debian:~$ find /usr/local/share/lua50/
okajima@Debian:~$ set | grep LUA