wahern / cqueues

Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
http://25thandclement.com/~william/projects/cqueues.html
MIT License
248 stars 37 forks source link

lua 5.1 can import cqueues, luajit cannot #237

Closed lePereT closed 4 years ago

lePereT commented 4 years ago

Hi all

I'm attempting to use cqueues on OpenWrt. It builds successfully (I specify the all5.1 options). The first example on http://25thandclement.com/~william/projects/cqueues.html :

local cqueues = require("cqueues")
local socket = require("cqueues.socket")

local con = socket.connect("www.google.com", 443)
con:starttls()

local inner = cqueues.new()
local outer = cqueues.new()

inner:wrap(function()
    con:write("GET / HTTP/1.0\n")
    con:write("Host: www.google.com:443\n\n")

    for ln in con:lines() do
        print(ln)
    end
end)

outer:wrap(function()
    assert(inner:loop())
end)

assert(outer:loop())

runs with lua 5.1 (when I replace the for loop with a while loop - maybe that should be noted in the docs for users on 5.1?) but doesn't run with luajit. Some output:

root@OpenWrt:~# luajit orig.lua
luajit: orig.lua:1: module 'cqueues' not found:
    no field package.preload['cqueues']
    no file './cqueues.lua'
    no file '/usr/share/luajit-2.1.0-beta2/cqueues.lua'
    no file '/usr/share/lua/cqueues.lua'
    no file '/usr/share/lua/cqueues/init.lua'
    no file '/usr/share/lua/cqueues.lua'
    no file '/usr/share/lua/cqueues/init.lua'
    no file './cqueues.so'
    no file '/usr/lib/lua/cqueues.so'
    no file '/usr/lib/lua/cqueues.so'
    no file '/usr/lib/lua/loadall.so'
stack traceback:
    [C]: in function 'require'
    orig.lua:1: in main chunk
    [C]: at 0x00404158
root@OpenWrt:~# find / -name *cqueues*
/rom/usr/lib/lua/_cqueues.so
/rom/usr/lib/lua/cqueues
/rom/usr/lib/lua/cqueues.lua
/rom/usr/lib/opkg/info/cqueues.control
/rom/usr/lib/opkg/info/cqueues.list
/rom/usr/lib/opkg/info/cqueues.prerm
/usr/lib/lua/_cqueues.so
/usr/lib/lua/cqueues
/usr/lib/lua/cqueues.lua
/usr/lib/opkg/info/cqueues.control
/usr/lib/opkg/info/cqueues.list
/usr/lib/opkg/info/cqueues.prerm
lePereT commented 4 years ago

This is an issue at my end. Please ignore!