You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2009/09/03 01:17:26 UTC

svn commit: r810729 - /couchdb/trunk/src/couchdb/couch_server.erl

Author: kocolosk
Date: Wed Sep  2 23:17:25 2009
New Revision: 810729

URL: http://svn.apache.org/viewvc?rev=810729&view=rev
Log:
skip some regex etc. if DB is already open

Modified:
    couchdb/trunk/src/couchdb/couch_server.erl

Modified: couchdb/trunk/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server.erl?rev=810729&r1=810728&r2=810729&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server.erl Wed Sep  2 23:17:25 2009
@@ -202,15 +202,15 @@
 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 @@
             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),