couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [26/50] chttpd commit: updated refs/heads/master to 58020ab
Date Thu, 28 Aug 2014 11:59:49 GMT
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/master
Commit: 5d50b2bb18219333f282572b1dd259321201055c
Parents: c14123f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Oct 17 16:09:42 2013 -0500
Committer: Robert Newson <rnewson@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


Mime
View raw message