Skip to content

Commit

Permalink
! fixed ruby18 specific code to work with ruby 1.9
Browse files Browse the repository at this point in the history
Relying on block arguments to overwrite local variables is bad.
  • Loading branch information
kschiess committed Feb 5, 2010
1 parent b52976d commit c567eb1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/toamqp/server_transport.rb
Expand Up @@ -23,17 +23,26 @@ def eof?
def listen
end

# Blocks until a message is received from the queue server.
#
def poll_for_message
m = nil
@queue.subscribe(:message_max => 1, :ack => true) do |message|
# DON'T return from here, it will hit a bug in Bunny. Subscription is
# not properly canceled on return, leaving our connection half good. (Ok,
# downright bad!)
m = message
end

return m
end

# Blocks until a request is made. Returns the transport that should be
# used for communication with that client.
#
def accept
# Wait for a message to arrive
message = nil
@queue.subscribe(:message_max => 1, :ack => true) do |message|
# DON'T return from here, it will hit a bug in Bunny
# This will only work in some rubies!
end

message = poll_for_message
packet = message[:payload]

transport_config = {
Expand Down

0 comments on commit c567eb1

Please sign in to comment.