lib/remcached/client.rb in astro-remcached-0.2.1 vs lib/remcached/client.rb in astro-remcached-0.2.2

- old
+ new

@@ -22,18 +22,10 @@ @connect_deferrable = EventMachine::DefaultDeferrable.new super @host, @port @connect_deferrable end - def close - close_connection - @connected = false - @pending.each do |opaque, callback| - callback.call :status => Errors::DISCONNECTED - end - end - def post_init @recv_buf = "" @recv_state = :header @connected = false end @@ -44,11 +36,11 @@ end RECONNECT_DELAY = 10 RECONNECT_JITTER = 5 def unbind - close + @connected = false EventMachine::Timer.new(RECONNECT_DELAY + rand(RECONNECT_JITTER), method(:reconnect)) end def send_packet(pkt) @@ -81,9 +73,17 @@ class Client < Connection def post_init super @opaque_counter = 0 + @pending = [] + end + + def unbind + super + @pending.each do |opaque, callback| + callback.call :status => Errors::DISCONNECTED + end @pending = [] end def send_request(pkt, &callback) @opaque_counter += 1