Navigation Menu

Skip to content

Commit

Permalink
Dispose client correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 15, 2015
1 parent 4a47f48 commit 3ed253b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/droonga/data_absorber_client.rb
Expand Up @@ -87,10 +87,11 @@ def run
"progressIntervalSeconds" => @progress_interval_seconds,
},
}
destination_client.subscribe(absorb_message) do |message|
client = create_destination_client
client.subscribe(absorb_message) do |message|
case message
when Droonga::Client::Error
destination_client.close
client.close
@error_message = message.to_s
else
case message["type"]
Expand All @@ -115,7 +116,7 @@ def run
end
end

def destination_client
def create_destination_client
options = {
:host => @host,
:port => @port,
Expand All @@ -124,7 +125,7 @@ def destination_client
:receiver_host => @receiver_host,
:receiver_port => @receiver_port,
}.merge(@client_options)
@destination_client ||= Droonga::Client.new(options)
Droonga::Client.new(options)
end

def source_node_suspendable?
Expand Down

0 comments on commit 3ed253b

Please sign in to comment.