diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-09-03 14:59:16 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-09-03 14:59:16 +0100 |
| commit | 06c5b1782b13f2346ae0dd888e4b3c57879d78a5 (patch) | |
| tree | a34b407c5b98e44eaa5f8a8064907432d8cb01fc /src | |
| parent | 054f774ab39eba201c67b542285647c3e36cb2d3 (diff) | |
| download | rabbitmq-server-git-06c5b1782b13f2346ae0dd888e4b3c57879d78a5.tar.gz | |
use client_terminate instead of monitoring for DOWN
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_msg_store.erl | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index 10e46fc7fd..1d53787a6d 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -377,7 +377,10 @@ client_init(Server, Ref) -> cur_file_cache_ets = CurFileCacheEts }. client_terminate(CState) -> - close_all_handles(CState), + Self = self(), + spawn(fun() -> + gen_server2:call(self(), {client_terminate, CState}) + end), ok. client_delete_and_terminate(CState, Server, Ref) -> @@ -616,10 +619,16 @@ handle_call(successfully_recovered_state, _From, State) -> handle_call({register_sync_callback, Fun}, {Pid, _}, State = #msstate { pid_to_fun = PTF }) -> - erlang:monitor(process, Pid), reply(ok, - State #msstate { pid_to_fun = dict:store(Pid, Fun, PTF) }). + State #msstate { pid_to_fun = dict:store(Pid, Fun, PTF) }); +handle_call({client_terminate, CState}, {Pid, _}, + State = #msstate { pid_to_fun = PTF, + pid_to_guids = PTG }) -> + ok = close_all_handles(CState), + reply(ok, + State #msstate { pid_to_fun = dict:erase(Pid, PTF), + pid_to_guids = dict:erase(Pid, PTG) }). handle_cast({write, Pid, Guid}, State = #msstate { current_file_handle = CurHdl, @@ -751,13 +760,6 @@ handle_cast({delete_client, CRef}, handle_info(timeout, State) -> noreply(internal_sync(State)); -handle_info({'DOWN', _MRef, process, Pid, _Reason}, - State = #msstate { pid_to_fun = PTF, - pid_to_guids = PTG }) -> - % A queue with a callback has died, so remove it from dicts. - {noreply, State #msstate { pid_to_fun = dict:erase(Pid, PTF), - pid_to_guids = dict:erase(Pid, PTG) }}; - handle_info({'EXIT', _Pid, Reason}, State) -> {stop, Reason, State}. |
