diff options
author | Damien F. Katz <damien@apache.org> | 2008-08-05 01:43:40 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-08-05 01:43:40 +0000 |
commit | 88ec14c220592c8c0db7869c9961423e9ee97e7c (patch) | |
tree | 67974f234e4a0201302506e3b7c56a73cf909376 /src/couchdb/couch_httpd.erl | |
parent | b218a0e7d425f7b3660433a17c6558f676524730 (diff) |
Added concurrent open db limit and a LRU cache for closing old databases when limit reached (configurable via MaxDbsOpen var in couch.ini). Refactored db update code in couch_db.erl into couch_db_updater.erl.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@682560 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 88271390..d1a4fa90 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -156,7 +156,8 @@ handle_db_request(Req, Method, {Path}) -> handle_db_request(Req, 'PUT', {DbName, []}) -> case couch_server:create(DbName, []) of - {ok, _Db} -> + {ok, Db} -> + couch_db:close(Db), send_json(Req, 201, {obj, [{ok, true}]}); {error, database_already_exists} -> Msg = io_lib:format("Database ~p already exists.", [DbName]), @@ -167,9 +168,13 @@ handle_db_request(Req, 'PUT', {DbName, []}) -> end; handle_db_request(Req, Method, {DbName, Rest}) -> - case couch_server:open(DbName) of + case couch_db:open(DbName, []) of {ok, Db} -> - handle_db_request(Req, Method, {DbName, Db, Rest}); + try + handle_db_request(Req, Method, {DbName, Db, Rest}) + after + couch_db:close(Db) + end; Error -> throw(Error) end; |