Skip to content

Commit

Permalink
Call disconnect on protocol when reconnecting in simple connection (#717
Browse files Browse the repository at this point in the history
)
  • Loading branch information
artemeff authored Nov 12, 2024
1 parent 9eee621 commit 71095dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/postgrex/simple_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ defmodule Postgrex.SimpleConnection do
@impl :gen_statem
def handle_event(type, content, statem_state, state)

def handle_event(:internal, {:connect, _}, @state, %{state: {mod, mod_state}} = state) do
def handle_event(:internal, {:connect, :reconnect}, @state, %{protocol: protocol} = state) do
Protocol.disconnect(:reconnect, protocol)
{:keep_state, %{state | protocol: nil}, {:next_event, :internal, {:connect, :init}}}
end

def handle_event(:internal, {:connect, :init}, @state, %{state: {mod, mod_state}} = state) do
opts =
case Keyword.get(opts(mod), :configure) do
{module, fun, args} -> apply(module, fun, [opts(mod) | args])
Expand Down

0 comments on commit 71095dc

Please sign in to comment.