Skip to content

Commit

Permalink
Merge pull request #44 from basho/bugfix/sdc/gen-cast-to-fsm-event
Browse files Browse the repository at this point in the history
Fix late registrations: riak_api_pb_server is no longer a gen_server
  • Loading branch information
Sean Cribbs committed Dec 18, 2013
2 parents 7af7ded + 14940cb commit f181a7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/riak_api_pb_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
-behaviour(gen_fsm).

%% API
-export([start_link/0, set_socket/2]).
-export([start_link/0, set_socket/2, service_registered/2]).

%% States
-export([wait_for_socket/2, wait_for_socket/3, wait_for_tls/2, wait_for_tls/3,
Expand Down Expand Up @@ -75,6 +75,11 @@ start_link() ->
set_socket(Pid, Socket) ->
gen_fsm:sync_send_event(Pid, {set_socket, Socket}, infinity).

%% @doc Notifies the server process of a newly registered PB service.
-spec service_registered(pid(), module()) -> ok.
service_registered(Pid, Mod) ->
gen_fsm:send_all_state_event(Pid, {registered, Mod}).

%% @doc The gen_server init/1 callback, initializes the
%% riak_api_pb_server.
-spec init(list()) -> {ok, #state{}}.
Expand Down
2 changes: 1 addition & 1 deletion src/riak_api_pb_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ service_registered(Mod) ->
undefined ->
ok;
_ ->
[ gen_server:cast(Pid, {registered, Mod}) ||
[ riak_api_pb_server:service_registered(Pid, Mod) ||
{_,Pid,_,_} <- supervisor:which_children(?MODULE) ],
ok
end.
Expand Down

0 comments on commit f181a7b

Please sign in to comment.