Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 927361057E for ; Wed, 2 Oct 2013 16:16:28 +0000 (UTC) Received: (qmail 73347 invoked by uid 500); 2 Oct 2013 16:16:24 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 73181 invoked by uid 500); 2 Oct 2013 16:16:23 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 71485 invoked by uid 99); 2 Oct 2013 16:16:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Oct 2013 16:16:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 168568AE0E8; Wed, 2 Oct 2013 16:16:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kocolosk@apache.org To: commits@couchdb.apache.org Date: Wed, 02 Oct 2013 16:16:23 -0000 Message-Id: <4b6272db1b2642eb9ea15c537f7b8ac0@git.apache.org> In-Reply-To: <56316c50683d47b78a5e0b6e51b6a036@git.apache.org> References: <56316c50683d47b78a5e0b6e51b6a036@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [6/7] git commit: updated refs/heads/1901-atomic-multipart-retries to d9837e1 Simplify doc_streamer initialization The unlink at the end is a noop, so we can simplify this to use spawn_link/3 and the fully-exported function call instead of spawn_link/1 and a closure. BugzID: 20822 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d9837e1d Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d9837e1d Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d9837e1d Branch: refs/heads/1901-atomic-multipart-retries Commit: d9837e1dadb7b49a032084021b8aa01f299dda4e Parents: 0b45050 Author: Adam Kocoloski Authored: Thu Sep 12 12:56:50 2013 -0400 Committer: Adam Kocoloski Committed: Wed Oct 2 12:11:24 2013 -0400 ---------------------------------------------------------------------- .../src/couch_replicator_api_wrap.erl | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/d9837e1d/src/couch_replicator/src/couch_replicator_api_wrap.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl index fccb759..2b8a636 100644 --- a/src/couch_replicator/src/couch_replicator_api_wrap.erl +++ b/src/couch_replicator/src/couch_replicator_api_wrap.erl @@ -834,6 +834,12 @@ rev_to_str({_Pos, _Id} = Rev) -> rev_to_str(Rev) -> Rev. +write_fun() -> + fun(Data) -> + receive {get_data, Ref, From} -> + From ! {data, Ref, Data} + end + end. stream_doc({JsonBytes, Atts, Boundary, Len}) -> case erlang:erase({doc_streamer, Boundary}) of @@ -843,17 +849,11 @@ stream_doc({JsonBytes, Atts, Boundary, Len}) -> _ -> ok end, - Self = self(), - DocStreamer = spawn_link(fun() -> - couch_doc:doc_to_multi_part_stream( - Boundary, JsonBytes, Atts, - fun(Data) -> - receive {get_data, Ref, From} -> - From ! {data, Ref, Data} - end - end, true), - unlink(Self) - end), + DocStreamer = spawn_link( + couch_doc, + doc_to_multi_part_stream, + [Boundary, JsonBytes, Atts, write_fun(), true] + ), erlang:put({doc_streamer, Boundary}, DocStreamer), {ok, <<>>, {Len, Boundary}}; stream_doc({0, Id}) ->