couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r950527 - in /couchdb/branches/0.11.x: src/couchdb/couch_server.erl src/couchdb/couch_view.erl test/etap/010-file-basics.t test/etap/040-util.t
Date Wed, 02 Jun 2010 12:24:10 GMT
Author: jan
Date: Wed Jun  2 12:24:10 2010
New Revision: 950527

URL: http://svn.apache.org/viewvc?rev=950527&view=rev
Log:
Merged r930363 from trunk:

Deterministic/synchronous shutdown code.

Modified:
    couchdb/branches/0.11.x/src/couchdb/couch_server.erl
    couchdb/branches/0.11.x/src/couchdb/couch_view.erl
    couchdb/branches/0.11.x/test/etap/010-file-basics.t
    couchdb/branches/0.11.x/test/etap/040-util.t

Modified: couchdb/branches/0.11.x/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_server.erl?rev=950527&r1=950526&r2=950527&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_server.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_server.erl Wed Jun  2 12:24:10 2010
@@ -212,7 +212,13 @@ open_async(Server, From, DbName, Filepat
     Opener = spawn_link(fun() ->
             Res = couch_db:start_link(DbName, Filepath, Options),
             gen_server:call(Parent, {open_result, DbName, Res}, infinity),
-            unlink(Parent)
+            unlink(Parent),
+            case Res of
+            {ok, DbReader} ->
+                unlink(DbReader);
+            _ ->
+                ok
+            end
         end),
     true = ets:insert(couch_dbs_by_name, {DbName, {opening, Opener, [From]}}),
     true = ets:insert(couch_dbs_by_pid, {Opener, DbName}),
@@ -299,15 +305,13 @@ handle_call({delete, DbName, _Options}, 
         case ets:lookup(couch_dbs_by_name, DbName) of
         [] -> Server;
         [{_, {opening, Pid, Froms}}] ->
-            exit(Pid, kill),
-            receive {'EXIT', Pid, _Reason} -> ok end,
+            couch_util:shutdown_sync(Pid),
             true = ets:delete(couch_dbs_by_name, DbName),
             true = ets:delete(couch_dbs_by_pid, Pid),
             [gen_server:send_result(F, not_found) || F <- Froms],
             Server#server{dbs_open=Server#server.dbs_open - 1};
         [{_, {opened, Pid, LruTime}}] ->
-            exit(Pid, kill),
-            receive {'EXIT', Pid, _Reason} -> ok end,
+            couch_util:shutdown_sync(Pid),
             true = ets:delete(couch_dbs_by_name, DbName),
             true = ets:delete(couch_dbs_by_pid, Pid),
             true = ets:delete(couch_dbs_by_lru, LruTime),
@@ -337,19 +341,9 @@ handle_cast(Msg, _Server) ->
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
-handle_info({'EXIT', _Pid, config_change}, _Server) ->
-    {stop, shutdown, Server};
-handle_info({'EXIT', Pid, Reason}, #server{dbs_open=DbsOpen}=Server) ->
-    [{Pid, DbName}] = ets:lookup(couch_dbs_by_pid, Pid),
-    case ets:lookup(couch_dbs_by_name, DbName) of
-    [{DbName, {opened, Pid, LruTime}}] ->
-        true = ets:delete(couch_dbs_by_lru, LruTime);
-    [{DbName, {opening, Pid, Froms}}] ->
-        [gen_server:reply(From, Reason) || From <- Froms]
-    end,
-    true = ets:delete(couch_dbs_by_pid, Pid),
-    true = ets:delete(couch_dbs_by_name, DbName),
-    {noreply, Server#server{dbs_open=DbsOpen - 1}};
-qhandle_info(Info, _Server) ->
-    exit({unknown_message, Info}).
+handle_info({'EXIT', _Pid, config_change}, Server) ->
+    {noreply, shutdown, Server};
+handle_info(Error, _Server) ->
+    ?LOG_ERROR("Unexpected message, restarting couch_server: ~p", [Error]),
+    exit(kill).
 

Modified: couchdb/branches/0.11.x/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_view.erl?rev=950527&r1=950526&r2=950527&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_view.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_view.erl Wed Jun  2 12:24:10 2010
@@ -312,8 +312,7 @@ do_reset_indexes(DbName, Root) ->
         fun({_DbName, Sig}) ->
             ?LOG_DEBUG("Killing update process for view group ~s. in database ~s.", [Sig,
DbName]),
             [{_, Pid}] = ets:lookup(group_servers_by_sig, {DbName, Sig}),
-            couch_util:shutdown_sync(Pid),
-            delete_from_ets(Pid, DbName, Sig)
+            couch_util:shutdown_sync(Pid)
         end, Names),
     delete_index_dir(Root, DbName),
     file:delete(Root ++ "/." ++ ?b2l(DbName) ++ "_temp").

Modified: couchdb/branches/0.11.x/test/etap/010-file-basics.t
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/test/etap/010-file-basics.t?rev=950527&r1=950526&r2=950527&view=diff
==============================================================================
--- couchdb/branches/0.11.x/test/etap/010-file-basics.t (original)
+++ couchdb/branches/0.11.x/test/etap/010-file-basics.t Wed Jun  2 12:24:10 2010
@@ -16,7 +16,7 @@ filename() -> test_util:build_file("test
 
 main(_) ->
     test_util:init_code_path(),
-    etap:plan(16),
+    etap:plan(19),
     case (catch test()) of
         ok ->
             etap:end_tests();

Modified: couchdb/branches/0.11.x/test/etap/040-util.t
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/test/etap/040-util.t?rev=950527&r1=950526&r2=950527&view=diff
==============================================================================
--- couchdb/branches/0.11.x/test/etap/040-util.t (original)
+++ couchdb/branches/0.11.x/test/etap/040-util.t Wed Jun  2 12:24:10 2010
@@ -17,7 +17,7 @@ main(_) ->
     test_util:init_code_path(),
     application:start(crypto),
 
-    etap:plan(16),
+    etap:plan(14),
     case (catch test()) of
         ok ->
             etap:end_tests();



Mime
View raw message