diff options
author | Robert Newson <robert.newson@cloudant.com> | 2012-01-16 22:11:20 +0000 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2012-01-16 22:11:20 +0000 |
commit | 5a7a1a536f32794910e8730ad93891f23a4e8895 (patch) | |
tree | bbda72f5212450293f239a820f02ff149955c700 /apps/couch/src | |
parent | effae95921f30d4847f8a8082f7e6f619c5108d7 (diff) |
Only set the process dictionary if exit was ok
Diffstat (limited to 'apps/couch/src')
-rw-r--r-- | apps/couch/src/couch_doc.erl | 13 |
1 files changed, 10 insertions, 3 deletions
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. |