couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [29/50] couch commit: updated refs/heads/master to 9d0ac7d
Date Thu, 28 Aug 2014 12:12:05 GMT
Fix multipart PUTs for document attachments

Accidentally dropped some work for multipart attachments in clusters
when we merged couch_att.erl


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

Branch: refs/heads/master
Commit: 8f57396e3051c06f8928f11aec82950e9e1c9cc9
Parents: 401f64f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Sun Aug 10 17:32:52 2014 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Aug 28 13:00:01 2014 +0100

----------------------------------------------------------------------
 src/couch_att.erl | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8f57396e/src/couch_att.erl
----------------------------------------------------------------------
diff --git a/src/couch_att.erl b/src/couch_att.erl
index e011402..720d435 100644
--- a/src/couch_att.erl
+++ b/src/couch_att.erl
@@ -527,6 +527,24 @@ flush_data(Fd, Fun, Att) when is_function(Fun) ->
             couch_db:with_stream(Fd, Att, fun(OutputStream) ->
                 write_streamed_attachment(OutputStream, Fun, AttLen)
             end)
+    end;
+flush_data(Fd, {follows, Parser, Ref}, Att) ->
+    ParserRef = erlang:monitor(process, Parser),
+    Fun = fun() ->
+        Parser ! {get_bytes, Ref, self()},
+        receive
+            {started_open_doc_revs, NewRef} ->
+                couch_doc:restart_open_doc_revs(Parser, Ref, NewRef);
+            {bytes, Ref, Bytes} ->
+                Bytes;
+            {'DOWN', ParserRef, _, _, Reason} ->
+                throw({mp_parser_died, Reason})
+        end
+    end,
+    try
+        flush_data(Fd, Fun, store(data, Fun, Att))
+    after
+        erlang:demonitor(ParserRef, [flush])
     end.
 
 
@@ -564,7 +582,25 @@ foldl({Fd, Sp}, Att, Fun, Acc) ->
     couch_stream:foldl(Fd, Sp, Md5, Fun, Acc);
 foldl(DataFun, Att, Fun, Acc) when is_function(DataFun) ->
     Len = fetch(att_len, Att),
-    fold_streamed_data(DataFun, Len, Fun, Acc).
+    fold_streamed_data(DataFun, Len, Fun, Acc);
+foldl({follows, Parser, Ref}, Att, Fun, Acc) ->
+    ParserRef = erlang:monitor(process, Parser),
+    DataFun = fun() ->
+        Parser ! {get_bytes, Ref, self()},
+        receive
+            {started_open_doc_revs, NewRef} ->
+                couch_doc:restart_open_doc_revs(Parser, Ref, NewRef);
+            {bytes, Ref, Bytes} ->
+                Bytes;
+            {'DOWN', ParserRef, _, _, Reason} ->
+                throw({mp_parser_died, Reason})
+        end
+    end,
+    try
+        foldl(DataFun, store(data, DataFun, Att), Fun, Acc)
+    after
+        erlang:demonitor(ParserRef, [flush])
+    end.
 
 
 range_foldl(Att, From, To, Fun, Acc) ->


Mime
View raw message