From 6e6813d355aa7371f63e46472faaa2b326ddf394 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Sat, 1 May 2010 08:37:53 -0400 Subject: rexi API module, and change msg sent if rexi worker dies --- src/rexi_server.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/rexi_server.erl') diff --git a/src/rexi_server.erl b/src/rexi_server.erl index 65110535..e06fd86d 100644 --- a/src/rexi_server.erl +++ b/src/rexi_server.erl @@ -30,7 +30,7 @@ handle_info({'DOWN', Ref, process, _, normal}, #st{workers=Workers} = St) -> handle_info({'DOWN', Ref, process, Pid, Reason}, #st{workers=Workers} = St) -> case find_worker(Ref, Workers) of {Pid, Ref, From} -> - notify_caller(From, Pid, Reason); + notify_caller(From, Reason); false -> ok end, {noreply, St#st{workers = remove_worker(Ref, Workers)}}; @@ -44,6 +44,8 @@ terminate(_Reason, St) -> code_change(_OldVsn, St, _Extra) -> {ok, St}. +%% @doc initializes a process started by rexi_server. +-spec init_p({pid(),reference()}, mfa()) -> any(). init_p(From, {M,F,A}) -> put(rexi_from, From), try apply(M, F, A) catch _:Reason -> exit(Reason) end. @@ -59,5 +61,5 @@ remove_worker(Ref, List) -> find_worker(Ref, List) -> lists:keyfind(Ref, 2, List). -notify_caller({Caller, CallerRef}, Pid, Reason) -> - Caller ! {worker_died, CallerRef, Pid, Reason}. +notify_caller({Caller, Ref}, Reason) -> + erlang:send(Caller, {rexi_EXIT, Ref, Reason}). -- cgit v1.2.3