summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-06-16 16:45:44 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-06-16 16:45:49 -0400
commit7d91ca78fb286cf216b91229b196c21dd5e192af (patch)
tree8ddd5e7421d789c748fd42d0c1b61791a04feda3 /src
parenteda54b6051020c6ab1812b6676338a6bad7f467d (diff)
don't hang when deleting a deleted DB
Diffstat (limited to 'src')
-rw-r--r--src/fabric_db_delete.erl24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/fabric_db_delete.erl b/src/fabric_db_delete.erl
index 0803400d..95b1a5ef 100644
--- a/src/fabric_db_delete.erl
+++ b/src/fabric_db_delete.erl
@@ -11,7 +11,7 @@
delete_db(DbName, Options) ->
Fullmap = partitions:all_parts(DbName),
RefPartMap = send_delete_calls(Fullmap, Options),
- Acc0 = {true, length(RefPartMap)},
+ Acc0 = {not_found, length(RefPartMap)},
case fabric_util:receive_loop(
RefPartMap, 1, fun handle_delete_msg/3, Acc0) of
{ok, _Results} ->
@@ -33,19 +33,19 @@ send_delete_calls(Parts, Options) ->
{Ref, Part}
end, Parts).
-handle_delete_msg(not_found, _, {NotFound, N}) ->
- {ok, {NotFound, N-1}};
-handle_delete_msg({rexi_EXIT, _Reason}, _, {NotFound, N}) ->
- {ok, {NotFound, N-1}};
+handle_delete_msg(ok, _, {_, 1}) ->
+ {stop, ok};
+handle_delete_msg(not_found, _, {Acc, 1}) ->
+ {stop, Acc};
+handle_delete_msg({rexi_EXIT, _Reason}, _, {Acc, N}) ->
+ % TODO is this the appropriate action to take, or should we abort?
+ {ok, {Acc, N-1}};
handle_delete_msg({rexi_DOWN, _, _, _}, _, _Acc) ->
{error, delete_db_fubar};
-handle_delete_msg(_, _, {NotFound, 1}) ->
- if
- NotFound -> {stop, not_found};
- true -> {stop, ok}
- end;
-handle_delete_msg(ok, _, {_NotFound, N}) ->
- {ok, {false, N-1}}.
+handle_delete_msg(not_found, _, {Acc, N}) ->
+ {ok, {Acc, N-1}};
+handle_delete_msg(ok, _, {_, N}) ->
+ {ok, {ok, N-1}}.
delete_fullmap(DbName) ->
case couch_db:open(<<"dbs">>, []) of