Isolate child processes to prevent crashing the whole thing.
Crashes will not propagate anymore so the server shouldn't crash by itself again.
This commit is contained in:
parent
576d246ccd
commit
536fdd5f50
@ -33,6 +33,7 @@ start() ->
|
||||
%% @doc Listen for connections.
|
||||
|
||||
listen() ->
|
||||
process_flag(trap_exit, true),
|
||||
{ok, LSocket} = ssl:listen(?GAME_PORT, ?GAME_LISTEN_OPTIONS),
|
||||
?MODULE:accept(LSocket).
|
||||
|
||||
@ -42,10 +43,15 @@ accept(LSocket) ->
|
||||
case ssl:transport_accept(LSocket, 5000) of
|
||||
{ok, CSocket} ->
|
||||
ssl:ssl_accept(CSocket),
|
||||
try
|
||||
log(0, "hello (new connection)"),
|
||||
egs_proto:send_hello(CSocket),
|
||||
PID = spawn_link(?MODULE, process, [CSocket, 0]),
|
||||
ssl:controlling_process(CSocket, PID);
|
||||
Pid = spawn_link(?MODULE, process, [CSocket, 0]),
|
||||
ssl:controlling_process(CSocket, Pid)
|
||||
catch
|
||||
_:_ ->
|
||||
reload
|
||||
end;
|
||||
_ ->
|
||||
reload
|
||||
end,
|
||||
|
@ -34,6 +34,7 @@ start() ->
|
||||
%% @doc Listen for connections.
|
||||
|
||||
listen(Port, SessionID) ->
|
||||
process_flag(trap_exit, true),
|
||||
{ok, LSocket} = ssl:listen(Port, ?LOGIN_LISTEN_OPTIONS),
|
||||
?MODULE:accept(LSocket, SessionID).
|
||||
|
||||
|
@ -32,6 +32,7 @@ start() ->
|
||||
%% @doc Listen for connections.
|
||||
|
||||
listen(Port) ->
|
||||
process_flag(trap_exit, true),
|
||||
{ok, LSocket} = gen_tcp:listen(Port, ?PATCH_LISTEN_OPTIONS),
|
||||
?MODULE:accept(LSocket).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user