Permalink
Browse files

Trying to make the reader loop thread easily notify EventSocket writi…

…ng users
  • Loading branch information...
1 parent f3083ab commit 355a780776a45700a76a790b313fdf885237130a Jay Phillips committed Feb 15, 2009
Showing with 6 additions and 4 deletions.
  1. +2 −2 lib/adhearsion/foundation/event_socket.rb
  2. +4 −2 lib/adhearsion/voip/asterisk/manager_interface.rb
@@ -108,11 +108,11 @@ def connect!
# @return [true,false] Returns true if successful or false if an exception occurred.
#
def send_data(data)
+ return false unless state.equal?(:connected)
# Note: TCPSocket#write is intrinsically Thread-safe
@socket.write data
- true
+ state.equal? :connected # Return false if there was a disconnect during the write. true otherwise
rescue Exception => exception
- puts "DRopped! #{exception}"
connection_dropped!
false
end
@@ -400,15 +400,17 @@ def write_loop
ahn_log.ami.error "Encountered an error writing a #{next_action.name} action. Trying to reconnect with #{@write_queue.size} other events waiting to be sent."
sleep 0.5
+ p @actions_connection
establish_actions_connection
+ p @actions_connection
end
end until write_successful
# If it's "causal event" action, we must wait here until it's fully responded
next_action.response if next_action.has_causal_events?
end
- rescue => e
- ahn_log.ami.error "ENCOUNTERED AN UNEXPECTED EXCEPTION IN THE AMI WRITE LOOP!"
+ rescue => error
+ ahn_log.ami.error "ENCOUNTERED AN UNEXPECTED EXCEPTION IN THE AMI WRITE LOOP! #{error} ", *error.backtrace
end
def check_connection

0 comments on commit 355a780

Please sign in to comment.