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/06 20:18:13 UTC
[23/27] couch-replicator commit: updated refs/heads/windsor-merge to
75e5ba1
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/windsor-merge
Commit: e87a9230ca24f79bcebf958978ac54ba6b9023eb
Parents: 603e4a8
Author: Mike Wallace <mi...@googlemail.com>
Authored: Mon Jan 27 14:31:22 2014 +0000
Committer: Robert Newson <rn...@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