Skip to content

Commit

Permalink
Move setting of ZMQ::LINGER to only ReadSocket.
Browse files Browse the repository at this point in the history
I think the purpose of setting LINGER to 0 was to make shutdown of read
sockets immediate. It was being set on bind, which doesn't always mean
the right thing, because a connect()'ed socket can just as often be a
PULL/SUB/REP.
  • Loading branch information
Al Tobey committed Mar 29, 2012
1 parent 37901b9 commit 31a18b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/celluloid/zmq/sockets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def setsockopt(option, value)
# Bind to the given 0MQ address
# Address should be in the form: tcp://1.2.3.4:5678/
def bind(addr)
setsockopt(::ZMQ::LINGER, @options[::ZMQ::LINGER])

unless ::ZMQ::Util.resultcode_ok? @socket.bind(addr)
raise IOError, "couldn't bind to #{addr}: #{::ZMQ::Util.error_string}"
end
Expand All @@ -55,6 +53,17 @@ def evented?

# Readable 0MQ sockets have a read method
module ReadableSocket
# always set LINGER on readable sockets
def bind(addr)
setsockopt(::ZMQ::LINGER, @options[::ZMQ::LINGER])
super(addr)
end

def connect(addr)
setsockopt(::ZMQ::LINGER, @options[::ZMQ::LINGER])
super(addr)
end

# Read a message from the socket
def read(buffer = '')
Celluloid.current_actor.wait_readable(@socket) if evented?
Expand Down

0 comments on commit 31a18b2

Please sign in to comment.