diff options
author | Robert Newson <robert.newson@cloudant.com> | 2012-01-16 19:03:03 +0000 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2012-01-16 19:03:03 +0000 |
commit | effae95921f30d4847f8a8082f7e6f619c5108d7 (patch) | |
tree | 6b4c1e78aeb1460755eabc05421ab1c94e2aff93 /apps/couch | |
parent | 121c71c8f0af5c76ae5b6a0383796a850f612388 (diff) |
Use spawn_monitor to await process completion
BugzID: 13133
Diffstat (limited to 'apps/couch')
-rw-r--r-- | apps/couch/src/couch_doc.erl | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/apps/couch/src/couch_doc.erl b/apps/couch/src/couch_doc.erl index 63ac0892..2c841835 100644 --- a/apps/couch/src/couch_doc.erl +++ b/apps/couch/src/couch_doc.erl @@ -484,13 +484,10 @@ 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} + fun(Next) -> mp_parse_doc(Next, []) end) end), Parser ! {get_doc_bytes, self()}, receive @@ -505,7 +502,7 @@ doc_from_multi_part_stream(ContentType, DataFun) -> A end, Doc#doc.atts), WaitFun = fun() -> - receive {Parser, finished} -> ok end, + receive {'DOWN', ParserRef, _, _, _} -> ok end, erlang:put(mochiweb_request_recv, true) end, {ok, Doc#doc{atts=Atts2}, WaitFun, Parser} |