Skip to content

Commit

Permalink
call disconnect on protocol when reconnecting in simple connection
Browse files Browse the repository at this point in the history
  • Loading branch information
artemeff committed Nov 12, 2024
1 parent 8a2b362 commit 9202615
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 9202615

Please sign in to comment.