You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/01 11:06:05 UTC
[29/49] chttpd commit: updated refs/heads/windsor-merge to 554ef74
Avoid VM log messages about uncaught errors
We defer doc updates to a child process so that we avoid mixing fabric
messages together between HTTP requests. This just makes the defer
cleaner so that the VM doesn't log when we throw a conflict error.
BugzId: 24264
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/5d50b2bb
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/5d50b2bb
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/5d50b2bb
Branch: refs/heads/windsor-merge
Commit: 5d50b2bb18219333f282572b1dd259321201055c
Parents: c14123f
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Oct 17 16:09:42 2013 -0500
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 30 11:17:44 2014 +0100
----------------------------------------------------------------------
src/chttpd_db.erl | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/5d50b2bb/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index b2b766b..7a1d69d 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -848,14 +848,29 @@ update_doc(#httpd{user_ctx=Ctx} = Req, Db, DocId, #doc{deleted=Deleted}=Doc,
_ ->
[UpdateType, {user_ctx,Ctx}, {w,W}]
end,
- {_, Ref} = spawn_monitor(fun() -> exit(fabric:update_doc(Db, Doc, Options)) end),
- Result = receive {'DOWN', Ref, _, _, Res} -> Res end,
- case Result of
- {{nocatch, Exception}, _Reason} ->
- % Exceptions from spawned processes are swallowed and returned, rethrow
- throw(Exception);
- _ ->
- ok
+
+ {_, Ref} = spawn_monitor(fun() ->
+ try fabric:update_doc(Db, Doc, Options) of
+ Resp ->
+ exit({exit_ok, Resp})
+ catch
+ throw:Reason ->
+ exit({exit_throw, Reason});
+ error:Reason ->
+ exit({exit_error, Reason});
+ exit:Reason ->
+ exit({exit_exit, Reason})
+ end
+ end),
+ Result = receive
+ {'DOWN', Ref, _, _, {exit_ok, Ret}} ->
+ Ret;
+ {'DOWN', Ref, _, _, {exit_throw, Reason}} ->
+ throw(Reason);
+ {'DOWN', Ref, _, _, {exit_error, Reason}} ->
+ erlang:error(Reason);
+ {'DOWN', Ref, _, _, {exit_exit, Reason}} ->
+ erlang:exit(Reason)
end,
case Result of