Skip to content

Commit

Permalink
Merge pull request #351 from ukrbublik/close-socket-on-error
Browse files Browse the repository at this point in the history
Close socket on timeout/error
  • Loading branch information
joshuawscott committed Jun 18, 2019
2 parents 7655de9 + 014fcf2 commit 6297def
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/kafka_ex/network_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ defmodule KafkaEx.NetworkClient do
:ok ->
case Socket.recv(socket, 0, timeout) do
{:ok, data} ->
:ok = Socket.setopts(socket, [:binary, {:packet, 4}, {:active, true}])
data

{:error, reason} ->
Expand All @@ -78,6 +79,8 @@ defmodule KafkaEx.NetworkClient do
} failed with #{inspect(reason)}"
)

Socket.close(socket)

{:error, reason}
end

Expand All @@ -88,11 +91,12 @@ defmodule KafkaEx.NetworkClient do
inspect(broker.port)
} failed with #{inspect(reason)}"
)

Socket.close(socket)

{:error, reason}
end

:ok = Socket.setopts(socket, [:binary, {:packet, 4}, {:active, true}])
response
end

Expand Down

0 comments on commit 6297def

Please sign in to comment.