From d5bf524c1dafd301a0fced8449ed90f7608beb72 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Fri, 13 May 2011 11:18:37 +0000 Subject: Merged revision 1102137 from trunk Make sure view group shutdowns when database is deleted or dies Added more assertions to test 200-view-group-no-db-leaks.t to ensure this doesn't happen anymore. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1102678 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_view_group.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/couchdb/couch_view_group.erl') diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl index b0cfe6e7..6ef1dcb4 100644 --- a/src/couchdb/couch_view_group.erl +++ b/src/couchdb/couch_view_group.erl @@ -84,6 +84,7 @@ init({{_, DbName, _} = InitArgs, ReturnPid, Ref}) -> ReturnPid ! {Ref, self(), {error, invalid_view_seq}}, ignore; _ -> + couch_db:monitor(Db), couch_db:close(Db), {ok, RefCounter} = couch_ref_counter:start([Fd]), {ok, #group_state{ @@ -339,7 +340,11 @@ handle_info({'EXIT', FromPid, {{nocatch, Reason}, _Trace}}, State) -> handle_info({'EXIT', FromPid, Reason}, State) -> ?LOG_DEBUG("Exit from linked pid: ~p", [{FromPid, Reason}]), - {stop, Reason, State}. + {stop, Reason, State}; + +handle_info({'DOWN',_,_,_,_}, State) -> + ?LOG_INFO("Shutting down view group server, monitored db is closing.", []), + {stop, normal, reply_all(State, shutdown)}. terminate(Reason, #group_state{updater_pid=Update, compactor_pid=Compact}=S) -> -- cgit v1.2.3