diff options
author | Jan Lehnardt <jan@apache.org> | 2010-02-28 02:41:05 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2010-02-28 02:41:05 +0000 |
commit | 5a9f96cf2646a0c9db468cd7876e75cdb9fda742 (patch) | |
tree | aca872035e7c6c5191c026dee592e1d5104432ac /src | |
parent | 64572be3b4b5e186013213bc2adf883d26d8f729 (diff) |
Apply fixes for COUCHDB-597 patch.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@917096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_changes.erl | 2 | ||||
-rw-r--r-- | src/couchdb/couch_rep_changes_feed.erl | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl index 7a9dcd93..35ea147f 100644 --- a/src/couchdb/couch_changes.erl +++ b/src/couchdb/couch_changes.erl @@ -117,6 +117,8 @@ get_changes_timeout(Args, Callback) -> case Timeout of undefined -> {DefaultTimeout, fun() -> stop end}; + infinity -> + {infinity, fun() -> stop end}; _ -> {lists:min([DefaultTimeout, Timeout]), fun() -> stop end} end; diff --git a/src/couchdb/couch_rep_changes_feed.erl b/src/couchdb/couch_rep_changes_feed.erl index 7c308800..343b445c 100644 --- a/src/couchdb/couch_rep_changes_feed.erl +++ b/src/couchdb/couch_rep_changes_feed.erl @@ -40,9 +40,7 @@ start_link(Parent, Source, StartSeq, PostProps) -> gen_server:start_link(?MODULE, [Parent, Source, StartSeq, PostProps], []). next(Server) -> - try gen_server:call(Server, next_changes, 31000) - catch exit:{timeout, _Reason} -> throw(changes_timeout) - end. + gen_server:call(Server, next_changes, infinity). stop(Server) -> gen_server:call(Server, stop). @@ -128,7 +126,8 @@ init([_Parent, Source, Since, PostProps] = InitArgs) -> "continuous"; false -> "normal" - end + end, + timeout = infinity }, ChangesPid = spawn_link(fun() -> ChangesFeedFun = couch_changes:handle_changes( @@ -369,9 +368,12 @@ decode_row(Row) -> maybe_stream_next(#state{reqid=nil}) -> ok; maybe_stream_next(#state{complete=false, count=N} = S) when N < ?BUFFER_SIZE -> + timer:cancel(get(timeout)), + {ok, Timeout} = timer:exit_after(31000, changes_timeout), + put(timeout, Timeout), ibrowse:stream_next(S#state.reqid); maybe_stream_next(_) -> - ok. + timer:cancel(get(timeout)). start_http_request(RawUrl) -> Url = ibrowse_lib:parse_url(RawUrl), |