Remove anonymous fun when starting replications This is a cherry-pick of: https://github.com/cloudant/couch_replicator/commit/faa28a6e7f5b460b1d3ca2f77b00ab7d5371021d Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/2e6d5c1a Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/2e6d5c1a Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/2e6d5c1a Branch: refs/heads/2707-merge-couch_replicator-fixes-from-cloudant-fork Commit: 2e6d5c1a6a74629509c247b620a877ddfce1daf5 Parents: dcb3886 Author: Robert Newson Authored: Wed Dec 3 11:30:51 2014 +0000 Committer: Mike Wallace Committed: Tue Jun 2 17:43:07 2015 +0100 ---------------------------------------------------------------------- src/couch_replicator_manager.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/2e6d5c1a/src/couch_replicator_manager.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl index 0fcb0c4..17c766e 100644 --- a/src/couch_replicator_manager.erl +++ b/src/couch_replicator_manager.erl @@ -32,6 +32,9 @@ -export([handle_db_event/3]). +%% exported but private +-export([start_replication/2]). + -include_lib("couch/include/couch_db.hrl"). -include_lib("mem3/include/mem3.hrl"). -include("couch_replicator.hrl"). @@ -451,7 +454,7 @@ maybe_start_replication(State, DbName, DocId, RepDoc) -> true = ets:insert(?DOC_TO_REP, {{DbName, DocId}, RepId}), couch_log:notice("Attempting to start replication `~s` (document `~s`).", [pp_rep_id(RepId), DocId]), - Pid = spawn_link(fun() -> start_replication(Rep, 0) end), + Pid = spawn_link(?MODULE, start_replication, [Rep, 0]), State#state{rep_start_pids = [Pid | State#state.rep_start_pids]}; #rep_state{rep = #rep{doc_id = DocId}} -> State; @@ -568,7 +571,7 @@ maybe_retry_replication(RepState, Error, State) -> couch_log:error("Error in replication `~s` (triggered by document `~s`): ~s" "~nRestarting replication in ~p seconds.", [pp_rep_id(RepId), DocId, to_binary(error_reason(Error)), Wait]), - Pid = spawn_link(fun() -> start_replication(Rep, Wait) end), + Pid = spawn_link(?MODULE, start_replication, [Rep, Wait]), State#state{rep_start_pids = [Pid | State#state.rep_start_pids]}.