Neopallium / lua-zmq

Lua zeromq2 binding
http://github.com/Neopallium/lua-zmq
MIT License
153 stars 36 forks source link

poller not loading properly in stock Lua VM #27

Closed icarus75 closed 12 years ago

icarus75 commented 12 years ago

I'm new to lua-zmq. My goal is to get zmq/lua-zmq running on OpenWRT. I've succeeded in x-compiling libzmq-2.1.11 and lua-zmq HEAD (78ac08). The zmq Lua module loads properly.

> require "zmq"
> context = zmq.init(1)

However, zmq.poller doesn't:

> require "zmq.poller"
> poller = zmq.poller(2)
stdin:1: attempt to call field 'poller' (a nil value)
stack traceback:
    stdin:1: in main chunk
    [C]: ?

The test was done with a stock Lua VM on both the x86 host as well as the MIPS embedded target. I remembered that I was able to get zmq.poller to load with an older lua-zmq commit. Compiling different lua-zmq commits in binary search mode gave this result: 23db47708b4a7ab8ff4c0012116eb87e2699cc88 successfully loads zmq.poller c5fc85c9cd183c0a373865ce939ba49efa706d06 [Fix bug in poller. ] fails to load zmq.poller

Makes sense, as c5fc85c9cd183c0a373865ce939ba49efa706d06 contains changes to the poller object. This is where I got stuck since I'm not used to working with LuaNativeObjects. Let me know if I can help out with some more debugging.

Neopallium commented 12 years ago

The 'zmq.poller' module doesn't register itself as a global. The Lua community is moving away from having modules auto register globals. The parent 'zmq' module (which is a binary module) still creates a global 'zmq', but that will most likely change in the future.

Please use: local zmq = require"zmq" local ctx = zmq.init(1) local zmq_poller = require"zmq.poller"

local poller = zmq_poller(2)

icarus75 commented 12 years ago

It's the first library I've come across that doesn't register itself as a global by default. It's pretty handy when poking around with the Lua interpreter.

Thanks for the clarification!