summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_server.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb/couch_server.erl')
-rw-r--r--src/couchdb/couch_server.erl33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 61794dea..325d4a12 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -147,9 +147,8 @@ init([]) ->
max_dbs_open=MaxDbsOpen,
start_time=httpd_util:rfc1123_date()}}.
-terminate(_Reason, _Srv) ->
- [couch_util:shutdown_sync(Pid) || {_, {Pid, _LruTime}} <-
- ets:tab2list(couch_dbs_by_name)],
+terminate(Reason, _Srv) ->
+ couch_util:terminate_linked(Reason),
ok.
all_databases() ->
@@ -188,7 +187,8 @@ try_close_lru(StartTime) ->
[{_, {MainPid, LruTime}}] = ets:lookup(couch_dbs_by_name, DbName),
case couch_db:is_idle(MainPid) of
true ->
- couch_util:shutdown_sync(MainPid),
+ exit(MainPid, kill),
+ receive {'EXIT', MainPid, _Reason} -> ok end,
true = ets:delete(couch_dbs_by_lru, LruTime),
true = ets:delete(couch_dbs_by_name, DbName),
true = ets:delete(couch_dbs_by_pid, MainPid),
@@ -284,7 +284,8 @@ handle_call({delete, DbName, _Options}, _From, Server) ->
case ets:lookup(couch_dbs_by_name, DbName) of
[] -> Server;
[{_, {Pid, LruTime}}] ->
- couch_util:shutdown_sync(Pid),
+ exit(Pid, kill),
+ receive {'EXIT', Pid, _Reason} -> ok end,
true = ets:delete(couch_dbs_by_name, DbName),
true = ets:delete(couch_dbs_by_pid, Pid),
true = ets:delete(couch_dbs_by_lru, LruTime),
@@ -314,18 +315,14 @@ 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) ->
- case ets:lookup(couch_dbs_by_pid, Pid) of
- [{Pid, DbName}] ->
- [{DbName, {Pid, LruTime}}] = ets:lookup(couch_dbs_by_name, DbName),
- true = ets:delete(couch_dbs_by_pid, Pid),
- true = ets:delete(couch_dbs_by_name, DbName),
- true = ets:delete(couch_dbs_by_lru, LruTime),
- {noreply, Server#server{dbs_open=DbsOpen - 1}};
- _ ->
- {stop,Reason,Server}
- end;
+handle_info({'EXIT', _Pid, config_change}, _Server) ->
+ exit(kill);
+handle_info({'EXIT', Pid, _Reason}, #server{dbs_open=DbsOpen}=Server) ->
+ [{Pid, DbName}] = ets:lookup(couch_dbs_by_pid, Pid),
+ [{DbName, {Pid, LruTime}}] = ets:lookup(couch_dbs_by_name, DbName),
+ true = ets:delete(couch_dbs_by_pid, Pid),
+ true = ets:delete(couch_dbs_by_name, DbName),
+ true = ets:delete(couch_dbs_by_lru, LruTime),
+ {noreply, Server#server{dbs_open=DbsOpen - 1}};
handle_info(Info, _Server) ->
exit({unknown_message, Info}).