Repository: couchdb-couch
Updated Branches:
  refs/heads/master 04b8c646e -> 56e5cbaf1


When reading attachments, avoid closing connections too early

Signal mochiweb to not send connection:close headers
in order for the socket to be reused.

Before this commit, this signaling was done too late.

COUCHDB-2834


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/c4624d95
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/c4624d95
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/c4624d95

Branch: refs/heads/master
Commit: c4624d95e45ec4b45f7c6ddfbc4cd61413ee1d63
Parents: e63f686
Author: Nick Vatamaniuc <vatam...@gmail.com>
Authored: Tue Apr 19 00:59:30 2016 -0400
Committer: Nick Vatamaniuc <vatam...@gmail.com>
Committed: Tue Apr 19 00:59:37 2016 -0400

----------------------------------------------------------------------
 src/couch_doc.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c4624d95/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index f973923..11063d9 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -403,13 +403,13 @@ doc_from_multi_part_stream(ContentType, DataFun, Ref) ->
         restart_open_doc_revs(Parser, Ref, NewRef);
     {{doc_bytes, Ref, DocBytes}, Parser, ParserRef} ->
         Doc = from_json_obj(?JSON_DECODE(DocBytes)),
+        erlang:put(mochiweb_request_recv, true),
         % we'll send the Parser process ID to the remote nodes so they can
         % retrieve their own copies of the attachment data
         WithParser = fun(follows) -> {follows, Parser, Ref}; (D) -> D end,
         Atts = [couch_att:transform(data, WithParser, A) || A <- Doc#doc.atts],
         WaitFun = fun() ->
-            receive {'DOWN', ParserRef, _, _, _} -> ok end,
-            erlang:put(mochiweb_request_recv, true)
+            receive {'DOWN', ParserRef, _, _, _} -> ok end
         end,
         {ok, Doc#doc{atts=Atts}, WaitFun, Parser};
     ok -> ok

Reply via email to