summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_rep.erl
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2010-02-24 04:15:58 +0000
committerJan Lehnardt <jan@apache.org>2010-02-24 04:15:58 +0000
commit0dd8f16e42f4f1d7206cc6d4c7e49b6cf420f725 (patch)
treeae6f796f543bc66bc2481550b6d078f6d99b7a95 /src/couchdb/couch_rep.erl
parent21bf95639695e0a3a8379ff2a03a0061246870b0 (diff)
Allow replication to be cancelled. Closes COUCHDB-664. Patch by Robert Newson.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@915664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep.erl')
-rw-r--r--src/couchdb/couch_rep.erl21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 4e6ad12d..82716809 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -68,13 +68,24 @@ replicate({Props}=PostBody, UserCtx) ->
[?MODULE]
},
- Server = start_replication_server(Replicator),
-
- case proplists:get_value(<<"continuous">>, Props, false) of
+ case proplists:get_value(<<"cancel">>, Props, false) of
true ->
- {ok, {continuous, ?l2b(BaseId)}};
+ case supervisor:terminate_child(couch_rep_sup, BaseId ++ Extension) of
+ {error, not_found} ->
+ {error, not_found};
+ ok ->
+ ok = supervisor:delete_child(couch_rep_sup, BaseId ++ Extension),
+ {ok, {cancelled, ?l2b(BaseId)}}
+ end;
false ->
- get_result(Server, PostBody, UserCtx)
+ Server = start_replication_server(Replicator),
+
+ case proplists:get_value(<<"continuous">>, Props, false) of
+ true ->
+ {ok, {continuous, ?l2b(BaseId)}};
+ false ->
+ get_result(Server, PostBody, UserCtx)
+ end
end.
checkpoint(Server) ->