From 5a7a1a536f32794910e8730ad93891f23a4e8895 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Mon, 16 Jan 2012 22:11:20 +0000 Subject: Only set the process dictionary if exit was ok --- apps/couch/src/couch_doc.erl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/couch/src/couch_doc.erl b/apps/couch/src/couch_doc.erl index 2c841835..923fbb0e 100644 --- a/apps/couch/src/couch_doc.erl +++ b/apps/couch/src/couch_doc.erl @@ -487,7 +487,8 @@ doc_from_multi_part_stream(ContentType, DataFun) -> {Parser, ParserRef} = spawn_monitor(fun() -> {<<"--">>, _, _} = couch_httpd:parse_multipart_request( ContentType, DataFun, - fun(Next) -> mp_parse_doc(Next, []) end) + fun(Next) -> mp_parse_doc(Next, []) end), + exit(ok) end), Parser ! {get_doc_bytes, self()}, receive @@ -502,8 +503,14 @@ doc_from_multi_part_stream(ContentType, DataFun) -> A end, Doc#doc.atts), WaitFun = fun() -> - receive {'DOWN', ParserRef, _, _, _} -> 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. -- cgit v1.2.3