Skip to content

iserve_master process crashes if client tries to add same server twice #1

@xoloki

Description

@xoloki

I ran into this issue when I had a gen_server module that called iserve:add_server/4 during init. If the module died, it was restarted by the supervisor, then during the call to iserve_master:call_add_server/2, iserve_server_sup:add_server/2 would return {error, {already_started, Pid}} rather than {ok, Pid}, which caused a badmatch in the iserve_master process, killing it.

The following patch fixes the issue:


---
 src/iserve_master.erl |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/iserve_master.erl b/src/iserve_master.erl
index 02872fc..879c6e9 100644
--- a/src/iserve_master.erl
+++ b/src/iserve_master.erl
@@ -51,9 +51,8 @@ code_change(_OldVsn, State, _Extra) ->
 %%% Internal functions

 call_add_server({_Starter, _Port, _Callback, _Context}=Conf, S) ->
-    {ok, Pid} = iserve_server_sup:add_server(S#state.supervisor, Conf),
+    Reply = iserve_server_sup:add_server(S#state.supervisor, Conf),
     %% TODO: Monitor the little bugger
-    Reply = {ok, Pid},
     {reply, Reply, S}.

 call_del_server(Pid, S) ->
-- 
1.6.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions