Fix process leak
All checks were successful
Build & Test / nix-build (pull_request) Successful in 4m34s
Build & Test / nix-build (push) Successful in 4m42s

This commit is contained in:
Kodi Craft 2024-10-05 12:06:33 +02:00
parent 7f3bb357db
commit 93f8432bd1
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -48,9 +48,6 @@ defmodule Amethyst.ConnectionHandler do
@spec loop(:gen_tcp.socket(), atom(), integer(), map()) :: no_return()
defp loop(socket, connstate, version, state) do
receive do
:closed ->
Logger.info("Connection #{inspect(socket)} closed.")
Process.exit(self(), :normal)
{:disconnect, reason} ->
disconnect(socket, reason, connstate, version, state)
Process.exit(self(), :normal)
@ -109,6 +106,9 @@ defmodule Amethyst.ConnectionHandler do
after 0 ->
# Received stuff from the connection receiver is lower priority
receive do
:closed ->
Logger.info("Connection #{inspect(socket)} closed.")
Process.exit(self(), :normal)
{:get_encryption, from} ->
send(from, Map.get(state, :decryption_state))
loop(socket, connstate, version, state)