couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewall...@apache.org
Subject [10/13] couch-replicator commit: updated refs/heads/master to 80708a9
Date Fri, 05 Jun 2015 16:47:50 GMT
Be more explicit on values of ?STREAM_STATUS

Also I should add a note about how the changes ending due to a throw
when processing the last_seq leads to the un-consumed stream messages.

This is a cherry-pick of:

https://github.com/cloudant/couch_replicator/commit/20d11c7d342ea77ffd5384d75e9cd570cbcbf5ba


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/8a3af420
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/8a3af420
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/8a3af420

Branch: refs/heads/master
Commit: 8a3af420a79a1a071647450a8e9e1d2f8cf3532e
Parents: 5ee42e1
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed May 20 17:26:59 2015 -0500
Committer: Mike Wallace <mikewallace@apache.org>
Committed: Fri Jun 5 17:20:26 2015 +0100

----------------------------------------------------------------------
 src/couch_replicator_httpc.erl | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/8a3af420/src/couch_replicator_httpc.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_httpc.erl b/src/couch_replicator_httpc.erl
index e61fba5..544c2ef 100644
--- a/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator_httpc.erl
@@ -36,7 +36,7 @@ setup(#httpdb{httpc_pool = nil, url = Url, http_connections = MaxConns}
= Db) ->
 
 
 send_req(HttpDb, Params1, Callback) ->
-    put(STREAM_STATUS, init),
+    put(?STREAM_STATUS, init),
     couch_stats:increment_counter([couch_replicator, requests]),
     Params2 = ?replace(Params1, qs,
         [{K, ?b2l(iolist_to_binary(V))} || {K, V} <- get_value(qs, Params1, [])]),
@@ -134,7 +134,7 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
             StreamDataFun = fun() ->
                 stream_data_self(HttpDb, Params, Worker, ReqId, Callback)
             end,
-            put(STREAM_STATUS, streaming),
+            put(?STREAM_STATUS, streaming),
             ibrowse:stream_next(ReqId),
             try
                 Ret = Callback(Ok, Headers, StreamDataFun),
@@ -170,22 +170,22 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
 % messages for the given ReqId on the floor since we're
 % no longer in the HTTP request.
 clean_mailbox({ibrowse_req_id, ReqId}) ->
-    case get(STREAM_STATUS) of
+    case get(?STREAM_STATUS) of
         streaming ->
             ibrowse:stream_next(ReqId),
             receive
                 {ibrowse_async_response, ReqId, _} ->
                     clean_mailbox({ibrowse_req_id, ReqId});
                 {ibrowse_async_response_end, ReqId} ->
-                    put(STREAM_STATUS, ended),
+                    put(?STREAM_STATUS, ended),
                     ok
             end;
-        _ ->
+        Status when Status == init; Status == ended ->
             receive
                 {ibrowse_async_response, ReqId, _} ->
                     clean_mailbox({ibrowse_req_id, ReqId});
                 {ibrowse_async_response_end, ReqId} ->
-                    put(STREAM_STATUS, ended),
+                    put(?STREAM_STATUS, ended),
                     ok
             end
     end;
@@ -236,7 +236,7 @@ stream_data_self(#httpdb{timeout = T} = HttpDb, Params, Worker, ReqId,
Cb) ->
         ibrowse:stream_next(ReqId),
         {Data, fun() -> stream_data_self(HttpDb, Params, Worker, ReqId, Cb) end};
     {Data, ibrowse_async_response_end} ->
-        put(STREAM_STATUS, ended),
+        put(?STREAM_STATUS, ended),
         {Data, fun() -> throw({maybe_retry_req, more_data_expected}) end}
     end.
 


Mime
View raw message