couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject couchdb-cassim git commit: Move fabric:open_doc calls outside of gen_server
Date Fri, 17 Apr 2015 23:11:58 GMT
Repository: couchdb-cassim
Updated Branches:
  refs/heads/2657-fix-cassim-fabric-calls [created] 7d9cc4717


Move fabric:open_doc calls outside of gen_server

COUCHDB-2657


Project: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/commit/7d9cc471
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/tree/7d9cc471
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-cassim/diff/7d9cc471

Branch: refs/heads/2657-fix-cassim-fabric-calls
Commit: 7d9cc47176c3f7899208e754ce8ec13d1ab6f070
Parents: 4c31793
Author: Russell Branca <chewbranca@apache.org>
Authored: Fri Apr 17 23:11:18 2015 +0000
Committer: Russell Branca <chewbranca@apache.org>
Committed: Fri Apr 17 23:11:18 2015 +0000

----------------------------------------------------------------------
 src/cassim_metadata_cache.erl | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-cassim/blob/7d9cc471/src/cassim_metadata_cache.erl
----------------------------------------------------------------------
diff --git a/src/cassim_metadata_cache.erl b/src/cassim_metadata_cache.erl
index 1e43dce..8c6a4f6 100644
--- a/src/cassim_metadata_cache.erl
+++ b/src/cassim_metadata_cache.erl
@@ -181,13 +181,17 @@ changes_callback({error, _}, EndSeq) ->
 
 
 load_meta_from_db(DbName, MetaId) ->
-    try fabric:open_doc(DbName, MetaId, []) of
-        {ok, Doc} ->
-            couch_doc:to_json_obj(Doc, []);
-        _Else ->
-            couch_log:warning("no record of meta ~s", [MetaId]),
-            undefined
-    catch error:database_does_not_exist ->
+    {Pid, Ref} = spawn_monitor(fun() ->
+        exit(fabric:open_doc(DbName, MetaId, []))
+    end),
+    receive {'DOWN', Ref, process, Pid, {ok, Doc}} ->
+        couch_doc:to_json_obj(Doc, []);
+    {'DOWN', Ref, process, Pid, _Error} ->
+        %% Error
+        undefined
+    after 61000 ->
+        erlang:demonitor(Ref, [flush]),
+        %% {error, timeout}
         undefined
     end.
 


Mime
View raw message