diff --git a/src/egs_game.erl b/src/egs_game.erl index c202da2..1aa6c84 100644 --- a/src/egs_game.erl +++ b/src/egs_game.erl @@ -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), - log(0, "hello (new connection)"), - egs_proto:send_hello(CSocket), - PID = spawn_link(?MODULE, process, [CSocket, 0]), - ssl:controlling_process(CSocket, PID); + try + log(0, "hello (new connection)"), + egs_proto:send_hello(CSocket), + Pid = spawn_link(?MODULE, process, [CSocket, 0]), + ssl:controlling_process(CSocket, Pid) + catch + _:_ -> + reload + end; _ -> reload end, diff --git a/src/egs_login.erl b/src/egs_login.erl index 55006b5..58cb704 100644 --- a/src/egs_login.erl +++ b/src/egs_login.erl @@ -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). diff --git a/src/egs_patch.erl b/src/egs_patch.erl index d1b376f..cbb0e12 100644 --- a/src/egs_patch.erl +++ b/src/egs_patch.erl @@ -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).