You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2008/08/22 19:37:05 UTC

svn commit: r688129 - in /incubator/couchdb/trunk/src/couchdb: couch_file.erl couch_server.erl couch_util.erl

Author: damien
Date: Fri Aug 22 10:37:04 2008
New Revision: 688129

URL: http://svn.apache.org/viewvc?rev=688129&view=rev
Log:
Fix for couch_server process crash when databases that don't exist are attempted to be opened. Removed old comments and fixed the AllowRemoteRestart testing option.

Modified:
    incubator/couchdb/trunk/src/couchdb/couch_file.erl
    incubator/couchdb/trunk/src/couchdb/couch_server.erl
    incubator/couchdb/trunk/src/couchdb/couch_util.erl

Modified: incubator/couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_file.erl?rev=688129&r1=688128&r2=688129&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_file.erl Fri Aug 22 10:37:04 2008
@@ -45,6 +45,11 @@
         {FdPid, ok} ->
             {ok, FdPid};
         {FdPid, Error} ->
+            case process_info(self(), trap_exit) of
+            {trap_exit, true} ->
+                receive {'EXIT', FdPid, _} -> ok end;
+            _ -> ok
+            end,
             Error
         end;
     Error ->

Modified: incubator/couchdb/trunk/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_server.erl?rev=688129&r1=688128&r2=688129&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_server.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_server.erl Fri Aug 22 10:37:04 2008
@@ -25,7 +25,6 @@
 -record(server,{
     root_dir = [],
     dbname_regexp,
-    remote_restart=[],
     max_dbs_open=100,
     current_dbs_open=0
     }).
@@ -96,7 +95,7 @@
     % will restart us and then we will pick up the new settings.
 
     RootDir = couch_config:get({"CouchDB", "RootDirectory"}, "."),
-    Options = couch_config:get({"CouchDB", "ServerOptions"}, []),
+    MaxDbsOpen = couch_config:get({"CouchDB", "MaxDbsOpen"}, "100"),
     Self = self(),
     ok = couch_config:register(
         fun({"CouchDB", "RootDirectory"}) ->
@@ -109,12 +108,9 @@
     ets:new(couch_dbs_by_pid, [set, private, named_table]),
     ets:new(couch_dbs_by_lru, [ordered_set, private, named_table]),
     process_flag(trap_exit, true),
-    MaxDbsOpen = proplists:get_value(max_dbs_open, Options),
-    RemoteRestart = proplists:get_value(remote_restart, Options),
     {ok, #server{root_dir=RootDir,
                 dbname_regexp=RegExp,
-                max_dbs_open=MaxDbsOpen,
-                remote_restart=RemoteRestart}}.
+                max_dbs_open=MaxDbsOpen}}.
 
 terminate(_Reason, _Server) ->
     ok.
@@ -264,10 +260,13 @@
     Error ->
         {reply, Error, Server}
     end;
-handle_call(remote_restart, _From, #server{remote_restart=false}=Server) ->
-    {reply, ok, Server};
-handle_call(remote_restart, _From, #server{remote_restart=true}=Server) ->
-    exit(couch_server_sup, restart),
+handle_call(remote_restart, _From, Server) ->
+    case couch_config:get({"CouchDB", "AllowRemoteRestart"}, "false") of
+    "true" ->
+        exit(couch_server_sup, restart);
+    _ ->
+        ok
+    end,
     {reply, ok, Server}.
 
 handle_cast(Msg, _Server) ->

Modified: incubator/couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_util.erl?rev=688129&r1=688128&r2=688129&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_util.erl Fri Aug 22 10:37:04 2008
@@ -136,30 +136,6 @@
     implode(T, Sep, [Sep,H|Acc]).
 
 
-% This is a simple ini parser. it just converts the string
-% contents of a file like this:
-%
-%; comments are ignored
-%;commentedoutvariable=foo
-%this is line that gets ignored because it has no equals sign
-%[this line gets ignored because it starts with a bracket but doesn't end with one
-%bloodtype=Ragu
-%[Some Section]
-%timeout=30
-%Default=zuh ; another comment (leading space or tab before a semi is necessary to be a comment if not at beginning of line)
-%[Another Section]
-%key with spaces=a value with stuff; and no comment
-%oops="it doesn't qet quoted strings with semis quite right ; it thinks it's part comment"
-%
-%And converts it into this:
-%[{{"","bloodtype"},"Ragu"},
-% {{"Some Section","timeout"},"30"},
-% {{"Some section","Default"}, "zuh"},
-% {{"Another Section", "key with spaces"}, "a value with stuff; and no comment"},
-% {{"Another Section", "oops"}, "\"it doesn't qet quoted strings with semis quite right"}]
-%
-
-
 drv_port() ->
     case get(couch_drv_port) of
     undefined ->