Skip to content
Browse files

When the socket is in the error state, we need to close the socket an…

…d open a new one.

This fixes error's in our rspecs when we do a lot of starting and stopping the EM reactor.
  • Loading branch information...
1 parent 3eb7ddd commit 73a75403b7f2929e4ca0818704998f95ccd53e4b @xtr3me committed Apr 13, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/snmp4em/manager.rb
View
6 lib/snmp4em/manager.rb
@@ -15,6 +15,12 @@ class << self
attr_reader :socket
def init_socket #:nodoc:
+ # When the socket is in error state, close the socket and re-open a new one.
+ if !@socket.nil? && @socket.error?
+ @socket.close_connection
+ @socket = nil
+ end
+
@socket ||= EM::open_datagram_socket("0.0.0.0", 0, Handler)
end

0 comments on commit 73a7540

Please sign in to comment.
Something went wrong with that request. Please try again.