Skip to content

Commit 4949b78

Browse files
committed
Revert "Proxy info messages to the adapter (#316)"
This reverts commit 5d088f7.
1 parent 249c291 commit 4949b78

File tree

5 files changed

+6
-137
lines changed

5 files changed

+6
-137
lines changed

.formatter.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test,examples,integration_test}/**/*.{ex,exs}"]
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test,integration_test}/**/*.{ex,exs}"]
44
]

examples/tcp_connection/lib/tcp_connection.ex

-17
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ defmodule TCPConnection do
6464

6565
case :gen_tcp.connect(host, port, socket_opts, timeout) do
6666
{:ok, sock} ->
67-
# Monitor the socket so we can react to it being closed. See handle_info/2.
68-
_ref = :inet.monitor(sock)
6967
{:ok, {sock, <<>>}}
7068

7169
{:error, reason} ->
@@ -145,21 +143,6 @@ defmodule TCPConnection do
145143
end
146144
end
147145

148-
# The handle_info callback is optional and can be removed if not needed.
149-
# Here it is used to react to `:inet.monitor/1` messages which arrive
150-
# when socket gets closed while the connection is idle.
151-
def handle_info({:DOWN, _ref, _type, sock, _info}, {sock, _buffer}) do
152-
{:disconnect, TCPConnection.Error.exception({:idle, :closed})}
153-
end
154-
155-
def handle_info(msg, state) do
156-
Logger.info(fn ->
157-
["#{__MODULE__} (", inspect(self()), ") missed message: ", inspect(msg)]
158-
end)
159-
160-
:ok
161-
end
162-
163146
@impl true
164147
def handle_close(_, _, s) do
165148
{:ok, nil, s}

integration_test/cases/info_test.exs

-100
This file was deleted.

lib/db_connection/connection.ex

+5-15
Original file line numberDiff line numberDiff line change
@@ -330,22 +330,12 @@ defmodule DBConnection.Connection do
330330
handle_timeout(s)
331331
end
332332

333-
def handle_event(:info, msg, :no_state, %{mod: mod, state: state} = s) do
334-
if function_exported?(mod, :handle_info, 2) do
335-
case apply(mod, :handle_info, [msg, state]) do
336-
:ok ->
337-
handle_timeout(s)
338-
339-
{:disconnect, err} ->
340-
{:keep_state, s, {:next_event, :internal, {:disconnect, {:log, err}}}}
341-
end
342-
else
343-
Logger.info(fn ->
344-
[inspect(mod), ?\s, ?(, inspect(self()), ") missed message: " | inspect(msg)]
345-
end)
333+
def handle_event(:info, msg, :no_state, %{mod: mod} = s) do
334+
Logger.info(fn ->
335+
[inspect(mod), ?\s, ?(, inspect(self()), ") missed message: " | inspect(msg)]
336+
end)
346337

347-
handle_timeout(s)
348-
end
338+
handle_timeout(s)
349339
end
350340

351341
@doc false

test/test_support.exs

-4
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ defmodule TestConnection do
150150
TestAgent.eval(:handle_deallocate, [query, cursor, opts, state])
151151
end
152152

153-
def handle_info(message, state) do
154-
TestAgent.eval(:handle_info, [message, state])
155-
end
156-
157153
defp put_agent_from_opts(opts) do
158154
Process.get(:agent) || Process.put(:agent, agent_from_opts(opts))
159155
end

0 commit comments

Comments
 (0)