Tasos Laskos
unread,May 3, 2013, 10:06:36 PM5/3/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to eventm...@googlegroups.com
Hey folks,
I'm experiencing some strange bahavior when calling EM.fork_reactor,
from what I can tell, it causes unbind to be called twice.
Under my more complex real-world application this causes some mayhem
because it triggers my retry-on-failure mechanism and results in messages
being sent multiple times.
I've pasted a sample client and server, what I'm seeing at the server's
side is the message in unbind to be shown twice when the fork call
is left in place and shown once when the call is removed.
I'm using EventMachine 1.0.3.
Any ideas?
----------------------------------------------------
Client:
-------------
require 'eventmachine'
module Client
def connection_completed
puts "Client - connected"
send_data 'Request'
end
def unbind( reason )
puts "Client - disconnected"
fail if !@done
@status = :closed
end
def receive_data( data )
#p data
ensure
@done = true
close_connection
end
end
EM.run do
EM.connect( 'localhost', 5000, Client )
end
----------------------------------------------------
Server:
-------------
require 'eventmachine'
module Server
def connection_completed
puts "Server - connected"
end
def receive_data( data )
p data
send_data 'Response'
EM.fork_reactor do
end
end
def unbind
puts "Server - disconnected"
end
end
EM.run do
::EM.start_server( 'localhost', 5000, Server )
end