couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [22/50] [abbrv] couch-replicator commit: updated refs/heads/1963-eunit-bigcouch to 3cf0b13
Date Thu, 28 Aug 2014 17:30:22 GMT
Clean up couch_replicator_httpc_pool pid on error

db_open cleans up the couch_replicator_httpc_pool process
if an error occurs accessing the remote Db.

BugzID: 27202


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/e87a9230
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/e87a9230
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/e87a9230

Branch: refs/heads/1963-eunit-bigcouch
Commit: e87a9230ca24f79bcebf958978ac54ba6b9023eb
Parents: 603e4a8
Author: Mike Wallace <mikewallace1979@googlemail.com>
Authored: Mon Jan 27 14:31:22 2014 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 29 15:26:37 2014 +0100

----------------------------------------------------------------------
 src/couch_replicator_api_wrap.erl | 45 +++++++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/e87a9230/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_api_wrap.erl b/src/couch_replicator_api_wrap.erl
index 16f7893..c6fe691 100644
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@ -69,20 +69,37 @@ db_open(Db, Options) ->
 
 db_open(#httpdb{} = Db1, _Options, Create) ->
     {ok, Db} = couch_replicator_httpc:setup(Db1),
-    case Create of
-    false ->
-        ok;
-    true ->
-        send_req(Db, [{method, put}], fun(_, _, _) -> ok end)
-    end,
-    send_req(Db, [{method, head}],
-        fun(200, _, _) ->
-            {ok, Db};
-        (401, _, _) ->
-            throw({unauthorized, ?l2b(db_uri(Db))});
-        (_, _, _) ->
-            throw({db_not_found, ?l2b(db_uri(Db))})
-        end);
+    try
+        case Create of
+        false ->
+            ok;
+        true ->
+            send_req(Db, [{method, put}],
+                fun(401, _, _) ->
+                    throw({unauthorized, ?l2b(db_uri(Db))});
+                (_, _, _) ->
+                    ok
+                end)
+        end,
+        send_req(Db, [{method, head}],
+            fun(200, _, _) ->
+                {ok, Db};
+            (401, _, _) ->
+                throw({unauthorized, ?l2b(db_uri(Db))});
+            (_, _, _) ->
+                throw({db_not_found, ?l2b(db_uri(Db))})
+            end)
+    catch
+        throw:Error ->
+            db_close(Db),
+            throw(Error);
+        error:Error ->
+            db_close(Db),
+            erlang:error(Error);
+        exit:Error ->
+            db_close(Db),
+            erlang:exit(Error)
+    end;
 db_open(DbName, Options, Create) ->
     try
         case Create of


Mime
View raw message