summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_server.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-09-02 23:17:25 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-09-02 23:17:25 +0000
commita41b4818cc496f07a07c324a8a1f7c82fbf0317a (patch)
treed8f3fcb9e6315348bc7fef6d03f9b9b8cb86a0d9 /src/couchdb/couch_server.erl
parente537632a0b357c265876517efccd0bc06950799a (diff)
skip some regex etc. if DB is already open
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@810729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_server.erl')
-rw-r--r--src/couchdb/couch_server.erl28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 93ba67d0..f407acf0 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -202,15 +202,15 @@ handle_call({set_max_dbs_open, Max}, _From, Server) ->
handle_call(get_server, _From, Server) ->
{reply, {ok, Server}, Server};
handle_call({open, DbName, Options}, _From, Server) ->
- DbNameList = binary_to_list(DbName),
- case check_dbname(Server, DbNameList) of
- ok ->
- Filepath = get_full_filename(Server, DbNameList),
- LruTime = now(),
- case ets:lookup(couch_dbs_by_name, DbName) of
- [] ->
+ LruTime = now(),
+ case ets:lookup(couch_dbs_by_name, DbName) of
+ [] ->
+ DbNameList = binary_to_list(DbName),
+ case check_dbname(Server, DbNameList) of
+ ok ->
case maybe_close_lru_db(Server) of
{ok, Server2} ->
+ Filepath = get_full_filename(Server, DbNameList),
case couch_db:start_link(DbName, Filepath, Options) of
{ok, MainPid} ->
true = ets:insert(couch_dbs_by_name, {DbName, {MainPid, LruTime}}),
@@ -225,14 +225,14 @@ handle_call({open, DbName, Options}, _From, Server) ->
CloseError ->
{reply, CloseError, Server}
end;
- [{_, {MainPid, PrevLruTime}}] ->
- true = ets:insert(couch_dbs_by_name, {DbName, {MainPid, LruTime}}),
- true = ets:delete(couch_dbs_by_lru, PrevLruTime),
- true = ets:insert(couch_dbs_by_lru, {LruTime, DbName}),
- {reply, {ok, MainPid}, Server}
+ Error ->
+ {reply, Error, Server}
end;
- Error ->
- {reply, Error, Server}
+ [{_, {MainPid, PrevLruTime}}] ->
+ true = ets:insert(couch_dbs_by_name, {DbName, {MainPid, LruTime}}),
+ true = ets:delete(couch_dbs_by_lru, PrevLruTime),
+ true = ets:insert(couch_dbs_by_lru, {LruTime, DbName}),
+ {reply, {ok, MainPid}, Server}
end;
handle_call({create, DbName, Options}, _From, Server) ->
DbNameList = binary_to_list(DbName),