summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_rep.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-09-02 04:48:36 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-09-02 04:48:36 +0000
commit4ad1897c6c3baff326012c5f660f74a97bd25347 (patch)
treed42e10af7293f950fec5aeff68c52254d150e10c /src/couchdb/couch_rep.erl
parent4536671ff6ca35e16665867ef40a1298e47f4626 (diff)
fix continuous replication occurring after identical normal one
Both forms of replication had the same child ID in the replication supervisor. As a result, a continuous replication triggered after an otherwise-identical normal replication would "forget" that it was continuous. The tricky part about this patch is that it lets a normal and a continuous replication with the same source and target execute simultaneously. That's inefficient, but other solutions are convoluted or give surprising results to the client. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@810358 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep.erl')
-rw-r--r--src/couchdb/couch_rep.erl17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index fa4d33bd..1411716f 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -56,9 +56,9 @@ replicate(Source, Target) when is_binary(Source), is_binary(Target) ->
%% function handling POST to _replicate
replicate({Props}=PostBody, UserCtx) ->
- RepId = make_replication_id(PostBody, UserCtx),
- Replicator = {RepId,
- {gen_server, start_link, [?MODULE, [RepId, PostBody, UserCtx], []]},
+ {BaseId, Extension} = make_replication_id(PostBody, UserCtx),
+ Replicator = {BaseId ++ Extension,
+ {gen_server, start_link, [?MODULE, [BaseId, PostBody, UserCtx], []]},
transient,
1,
worker,
@@ -69,7 +69,7 @@ replicate({Props}=PostBody, UserCtx) ->
case proplists:get_value(<<"continuous">>, Props, false) of
true ->
- {ok, {continuous, ?l2b(RepId)}};
+ {ok, {continuous, ?l2b(BaseId)}};
false ->
get_result(Server, PostBody, UserCtx)
end.
@@ -361,7 +361,14 @@ make_replication_id({Props}, UserCtx) ->
% Port = mochiweb_socket_server:get(couch_httpd, port),
Src = get_rep_endpoint(UserCtx, proplists:get_value(<<"source">>, Props)),
Tgt = get_rep_endpoint(UserCtx, proplists:get_value(<<"target">>, Props)),
- couch_util:to_hex(erlang:md5(term_to_binary([HostName, Src, Tgt]))).
+ Base = couch_util:to_hex(erlang:md5(term_to_binary([HostName, Src, Tgt]))),
+ Extension = case proplists:get_value(<<"continuous">>, Props, false) of
+ true ->
+ "+continuous";
+ false ->
+ ""
+ end,
+ {Base, Extension}.
maybe_add_trailing_slash(Url) ->
re:replace(Url, "[^/]$", "&/", [{return, list}]).