Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19F19116D0 for ; Thu, 28 Aug 2014 17:30:08 +0000 (UTC) Received: (qmail 13570 invoked by uid 500); 28 Aug 2014 17:30:02 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 13242 invoked by uid 500); 28 Aug 2014 17:30:02 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 12416 invoked by uid 99); 28 Aug 2014 17:30:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 17:30:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3FE54A04B07; Thu, 28 Aug 2014 17:30:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chewbranca@apache.org To: commits@couchdb.apache.org Date: Thu, 28 Aug 2014 17:30:22 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [22/50] [abbrv] couch-replicator commit: updated refs/heads/1963-eunit-bigcouch to 3cf0b13 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 Authored: Mon Jan 27 14:31:22 2014 +0000 Committer: Robert Newson 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