Author: fdmanana
Date: Thu Jun 16 10:53:42 2011
New Revision: 1136370

URL: http://svn.apache.org/viewvc?rev=1136370&view=rev
Log:
Fix terminate function in couch_server

couch_server was not doing a synchronous shutdown of all
the open databases when terminating (due to an error or
server restart) because the list comprehension was filtering
the couch_dbs_by_name ets table entries with a wrong pattern.

Patch by Andrey Somov. Thanks.
Closes COUCHDB-1196.



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=1136370&r1=1136369&r2=1136370&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server.erl Thu Jun 16 10:53:42 2011
@@ -151,9 +151,11 @@ init([]) ->
                 start_time=httpd_util:rfc1123_date()}}.
 
 terminate(_Reason, _Srv) ->
-    [couch_util:shutdown_sync(Pid) || {_, {Pid, _LruTime}} <-
-            ets:tab2list(couch_dbs_by_name)],
-    ok.
+    lists:foreach(
+        fun({_, {_, Pid, _}}) ->
+                couch_util:shutdown_sync(Pid)
+        end,
+        ets:tab2list(couch_dbs_by_name)).
 
 all_databases() ->
     {ok, #server{root_dir=Root}} = gen_server:call(couch_server, get_server),


Reply via email to