summaryrefslogtreecommitdiff
path: root/apps/couch
diff options
context:
space:
mode:
authorRobert Newson <robert.newson@gmail.com>2012-01-17 14:16:09 -0800
committerRobert Newson <robert.newson@gmail.com>2012-01-17 14:16:09 -0800
commit42334faf4f660b48d29a92f62b92f62ab4700613 (patch)
treebbda72f5212450293f239a820f02ff149955c700 /apps/couch
parent121c71c8f0af5c76ae5b6a0383796a850f612388 (diff)
parent5a7a1a536f32794910e8730ad93891f23a4e8895 (diff)
Merge pull request #91 from cloudant/13133-attachment-replication
Fix attachment replication BugzID: 13133
Diffstat (limited to 'apps/couch')
-rw-r--r--apps/couch/src/couch_doc.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/couch/src/couch_doc.erl b/apps/couch/src/couch_doc.erl
index 63ac0892..923fbb0e 100644
--- a/apps/couch/src/couch_doc.erl
+++ b/apps/couch/src/couch_doc.erl
@@ -484,13 +484,11 @@ atts_to_mp([Att | RestAtts], Boundary, WriteFun,
doc_from_multi_part_stream(ContentType, DataFun) ->
- Parent = self(),
- Parser = spawn_link(fun() ->
+ {Parser, ParserRef} = spawn_monitor(fun() ->
{<<"--">>, _, _} = couch_httpd:parse_multipart_request(
ContentType, DataFun,
fun(Next) -> mp_parse_doc(Next, []) end),
- unlink(Parent),
- Parent ! {self(), finished}
+ exit(ok)
end),
Parser ! {get_doc_bytes, self()},
receive
@@ -505,8 +503,14 @@ doc_from_multi_part_stream(ContentType, DataFun) ->
A
end, Doc#doc.atts),
WaitFun = fun() ->
- receive {Parser, finished} -> ok end,
- erlang:put(mochiweb_request_recv, true)
+ receive {'DOWN', ParserRef, _, _, Result} -> ok end,
+ case Result of
+ ok ->
+ erlang:put(mochiweb_request_recv, true);
+ _Else ->
+ ?LOG_ERROR("Unexpected msg while parsing multipart stream: ~p",
+ [Result])
+ end
end,
{ok, Doc#doc{atts=Atts2}, WaitFun, Parser}
end.