From 855bb7dcda1cef59c449d62de35d9c4d74683731 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Wed, 18 Jan 2012 13:39:37 +0000 Subject: Revert use of spawn_monitor As Filipe correctly points out, we want the parent to die if the child dies. --- apps/couch/src/couch_doc.erl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'apps') 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. -- cgit v1.2.3