* VRFS-1653 - don't bother with cleanup in onerror, and make startup of EventMachine better (VRFS-1659)
This commit is contained in:
parent
ece5ee80f8
commit
3e2f39cc85
|
|
@ -36,8 +36,9 @@ module JamWebEventMachine
|
|||
end
|
||||
|
||||
|
||||
def self.run_em(calling_thread = nil)
|
||||
def self.run_em(calling_thread = nil, semaphore = nil, ran = {})
|
||||
|
||||
semaphore.lock if semaphore
|
||||
EM.run do
|
||||
# this is global because we need to check elsewhere if we are currently connected to amqp before signalling success with some APIs, such as 'create session'
|
||||
$amqp_connection_manager = AmqpConnectionManager.new(true, 4, :host => APP_CONFIG.rabbitmq_host, :port => APP_CONFIG.rabbitmq_port)
|
||||
|
|
@ -54,6 +55,8 @@ module JamWebEventMachine
|
|||
end
|
||||
end
|
||||
|
||||
ran[:ran] = true
|
||||
semaphore.unlock if semaphore
|
||||
calling_thread.wakeup if calling_thread
|
||||
end
|
||||
end
|
||||
|
|
@ -66,11 +69,17 @@ module JamWebEventMachine
|
|||
|
||||
def self.run
|
||||
|
||||
ran = {}
|
||||
semaphore = Mutex.new
|
||||
current = Thread.current
|
||||
Thread.new do
|
||||
run_em(current)
|
||||
run_em(current, semaphore, ran)
|
||||
end
|
||||
Thread.stop
|
||||
semaphore.synchronize {
|
||||
unless ran[:ran]
|
||||
semaphore.sleep(10)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def self.start
|
||||
|
|
|
|||
|
|
@ -245,13 +245,6 @@ module JamWebsockets
|
|||
else
|
||||
@log.error "generic error: #{error} #{error.backtrace}"
|
||||
end
|
||||
|
||||
unless error.to_s.include? "Close handshake un-acked"
|
||||
cleanup_client(client)
|
||||
else
|
||||
@log.info "skipping cleanup because error is for dead connection: https://github.com/igrigorik/em-websocket/issues/122"
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
client.onmessage { |msg|
|
||||
|
|
|
|||
Loading…
Reference in New Issue