Skip to content

Commit 9202615

Browse files
committed
call disconnect on protocol when reconnecting in simple connection
1 parent 8a2b362 commit 9202615

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/postgrex/simple_connection.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ defmodule Postgrex.SimpleConnection do
337337
@impl :gen_statem
338338
def handle_event(type, content, statem_state, state)
339339

340-
def handle_event(:internal, {:connect, _}, @state, %{state: {mod, mod_state}} = state) do
340+
def handle_event(:internal, {:connect, :reconnect}, @state, %{protocol: protocol} = state) do
341+
Protocol.disconnect(:reconnect, protocol)
342+
{:keep_state, %{state | protocol: nil}, {:next_event, :internal, {:connect, :init}}}
343+
end
344+
345+
def handle_event(:internal, {:connect, :init}, @state, %{state: {mod, mod_state}} = state) do
341346
opts =
342347
case Keyword.get(opts(mod), :configure) do
343348
{module, fun, args} -> apply(module, fun, [opts(mod) | args])

0 commit comments

Comments
 (0)