summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRobert Newson <robert.newson@cloudant.com>2012-01-18 13:39:37 +0000
committerRobert Newson <robert.newson@cloudant.com>2012-01-18 13:40:02 +0000
commit855bb7dcda1cef59c449d62de35d9c4d74683731 (patch)
treeec44063fefeab642760ccc8718be822d93946191 /apps
parentb5c6252b4f99092215f46fe62be5b124eeac734d (diff)
Revert use of spawn_monitor
As Filipe correctly points out, we want the parent to die if the child dies.
Diffstat (limited to 'apps')
-rw-r--r--apps/couch/src/couch_doc.erl16
1 files changed, 6 insertions, 10 deletions
diff --git a/apps/couch/src/couch_doc.erl b/apps/couch/src/couch_doc.erl
index 923fbb0e..63ac0892 100644
--- a/apps/couch/src/couch_doc.erl
+++ b/apps/couch/src/couch_doc.erl
@@ -484,11 +484,13 @@ atts_to_mp([Att | RestAtts], Boundary, WriteFun,
doc_from_multi_part_stream(ContentType, DataFun) ->
- {Parser, ParserRef} = spawn_monitor(fun() ->
+ Parent = self(),
+ Parser = spawn_link(fun() ->
{<<"--">>, _, _} = couch_httpd:parse_multipart_request(
ContentType, DataFun,
fun(Next) -> mp_parse_doc(Next, []) end),
- exit(ok)
+ unlink(Parent),
+ Parent ! {self(), finished}
end),
Parser ! {get_doc_bytes, self()},
receive
@@ -503,14 +505,8 @@ doc_from_multi_part_stream(ContentType, DataFun) ->
A
end, Doc#doc.atts),
WaitFun = fun() ->
- 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
+ receive {Parser, finished} -> ok end,
+ erlang:put(mochiweb_request_recv, true)
end,
{ok, Doc#doc{atts=Atts2}, WaitFun, Parser}
end.