summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-06-07 09:32:02 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-06-07 09:34:07 -0400
commit25238d8967ec52cfc8d132b1a2747ba587787e04 (patch)
tree71fe30a53639a83b11db8b9e36aa9b56ac53a23f
parentea6edcec3944e502e3a6aade48d95e62c646f27f (diff)
cleanup after we're done
-rw-r--r--src/fabric_util.erl5
-rw-r--r--src/fabric_view_all_docs.erl4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index 760e511c..f0ab213d 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -1,6 +1,6 @@
-module(fabric_util).
--export([submit_jobs/3, recv/4, receive_loop/4, receive_loop/6]).
+-export([submit_jobs/3, cleanup/1, recv/4, receive_loop/4, receive_loop/6]).
-include("fabric.hrl").
@@ -11,6 +11,9 @@ submit_jobs(Shards, EndPoint, ExtraArgs) ->
Shard#shard{ref = Ref}
end, Shards).
+cleanup(Workers) ->
+ [rexi:kill(Node, Ref) || #shard{node=Node, ref=Ref} <- Workers].
+
recv(Workers, Keypos, Fun, Acc0) ->
receive_loop(Workers, Keypos, Fun, Acc0).
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index b91f0665..6cdc66c5 100644
--- a/src/fabric_view_all_docs.erl
+++ b/src/fabric_view_all_docs.erl
@@ -21,12 +21,14 @@ go(DbName, #view_query_args{keys=nil} = QueryArgs, Callback, Acc0) ->
limit = Limit,
user_acc = Acc0
},
- case fabric_util:receive_loop(Workers, #shard.ref, fun handle_message/3,
+ try fabric_util:receive_loop(Workers, #shard.ref, fun handle_message/3,
State, infinity, 5000) of
{ok, NewState} ->
{ok, NewState#collector.user_acc};
Error ->
Error
+ after
+ fabric_util:cleanup(Workers)
end;
go(DbName, QueryArgs, Callback, Acc0) ->