celluloid / celluloid-zmq

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid actors that talk over the 0MQ protocol
https://celluloid.io
MIT License
83 stars 25 forks source link

Socket monitoring #18

Closed grantr closed 11 years ago

grantr commented 11 years ago

This branch adds a SocketMonitor actor that monitors socket events using the zmq_socket_monitor feature in zeromq 3.2.

It only works with ffi-rzmq > 0.9.7, which is why the Gemfile depends on git master. When a new version of ffi-rzmq is released (0.9.8?) that can be removed.

require 'celluloid/zmq'
socket = Celluloid::ZMQ::PubSocket.new
Celluloid::ZMQ::SocketMonitor.new(socket, "socket.monitor")
socket.bind("tcp://127.0.0.1:58000")
# got listening socket event: event [8], addr [tcp://127.0.0.1:58004], fd [17], field2 [17]
tarcieri commented 11 years ago

Assertion failed: ok (mailbox.cpp:79)

o_O

grantr commented 11 years ago

What version of zeromq are you using?

tarcieri commented 11 years ago

This was on Travis. The tests are failing on 1.9.3:

https://travis-ci.org/celluloid/celluloid-zmq/jobs/4077824

tarcieri commented 11 years ago

@grantr @chuckremes new error this time:

Assertion failed: pfd.revents & POLLIN (signaler.cpp:155)

Something seems seriously broken :(

grantr commented 11 years ago

I had never seen that error myself until today. It's probably a rarely-seen timing bug that travis is running into. It happened on shutdown.

D, [2013-01-21T19:59:50.456616 #7601] DEBUG -- default: Terminating 16 actors...
/home/grantr/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/thread.rb:71:in `sleep': Interrupt
    from /home/grantr/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/thread.rb:71:in `wait'
    from /home/grantr/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/celluloid-b5803bb047ef/lib/celluloid/thread_handle.rb:40:in `block in join'
    from <internal:prelude>:10:in `synchronize'
    from /home/grantr/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/celluloid-b5803bb047ef/lib/celluloid/thread_handle.rb:40:in `join'
    from /home/grantr/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/celluloid-b5803bb047ef/lib/celluloid/actor.rb:158:in `join'
    from examples/server.rb:9:in `<main>'
Assertion failed: pfd.revents & POLLIN (signaler.cpp:155)
halorgium commented 11 years ago

FYI, ffi-rzmq 1.0.0 is released. It might be better to use a handler object responding to call rather than requiring inheritance.

@grantr do you have a simple test script you could gist for this?

halorgium commented 11 years ago

This seems like an interesting idea, but needs a bit of work now that all of the deps have changed.