You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2010/02/28 03:41:05 UTC

svn commit: r917096 - in /couchdb/trunk/src/couchdb: couch_changes.erl couch_rep_changes_feed.erl

Author: jan
Date: Sun Feb 28 02:41:05 2010
New Revision: 917096

URL: http://svn.apache.org/viewvc?rev=917096&view=rev
Log:
Apply fixes for COUCHDB-597 patch.

Modified:
    couchdb/trunk/src/couchdb/couch_changes.erl
    couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl

Modified: couchdb/trunk/src/couchdb/couch_changes.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_changes.erl?rev=917096&r1=917095&r2=917096&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_changes.erl (original)
+++ couchdb/trunk/src/couchdb/couch_changes.erl Sun Feb 28 02:41:05 2010
@@ -117,6 +117,8 @@
         case Timeout of
         undefined ->
             {DefaultTimeout, fun() -> stop end};
+        infinity ->
+            {infinity, fun() -> stop end};
         _ ->
             {lists:min([DefaultTimeout, Timeout]), fun() -> stop end}
         end;

Modified: couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl?rev=917096&r1=917095&r2=917096&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl Sun Feb 28 02:41:05 2010
@@ -40,9 +40,7 @@
     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 @@
                 "continuous";
             false ->
                 "normal"
-        end
+        end,
+        timeout = infinity
     },
     ChangesPid = spawn_link(fun() ->
         ChangesFeedFun = couch_changes:handle_changes(
@@ -369,9 +368,12 @@
 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),