summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_rep_changes_feed.erl
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2010-02-26 23:43:28 +0000
committerJan Lehnardt <jan@apache.org>2010-02-26 23:43:28 +0000
commit64572be3b4b5e186013213bc2adf883d26d8f729 (patch)
treeb4dd635cbdd25189c97538e723639c8c058839d9 /src/couchdb/couch_rep_changes_feed.erl
parent4cefde131f1992c70f66c527435a715290174423 (diff)
Avoid replication task crashes by imporoving timeout handling.
Closes COUCHDB-597. Patch by Randall Leeds. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@916868 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep_changes_feed.erl')
-rw-r--r--src/couchdb/couch_rep_changes_feed.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/couchdb/couch_rep_changes_feed.erl b/src/couchdb/couch_rep_changes_feed.erl
index 67cfabe4..7c308800 100644
--- a/src/couchdb/couch_rep_changes_feed.erl
+++ b/src/couchdb/couch_rep_changes_feed.erl
@@ -40,7 +40,9 @@ start_link(Parent, Source, StartSeq, PostProps) ->
gen_server:start_link(?MODULE, [Parent, Source, StartSeq, PostProps], []).
next(Server) ->
- gen_server:call(Server, next_changes, infinity).
+ try gen_server:call(Server, next_changes, 31000)
+ catch exit:{timeout, _Reason} -> throw(changes_timeout)
+ end.
stop(Server) ->
gen_server:call(Server, stop).
@@ -83,8 +85,7 @@ init([_Parent, #http_db{}=Source, Since, PostProps] = Args) ->
resource = "_changes",
qs = QS,
conn = Pid,
- options = [{stream_to, {self(), once}}, {response_format, binary},
- {inactivity_timeout, 31000}], % miss 3 heartbeats, assume death
+ options = [{stream_to, {self(), once}}, {response_format, binary}],
headers = Source#http_db.headers -- [{"Accept-Encoding", "gzip"}]
},
{ibrowse_req_id, ReqId} = couch_rep_httpc:request(Req),
@@ -202,6 +203,9 @@ handle_info({'EXIT', From, Reason}, #state{changes_loop=From} = State) ->
?LOG_ERROR("changes_loop died with reason ~p", [Reason]),
{stop, changes_loop_died, State};
+handle_info({'EXIT', _From, normal}, State) ->
+ {noreply, State};
+
handle_info(Msg, State) ->
?LOG_DEBUG("unexpected message at changes_feed ~p", [Msg]),
{noreply, State}.