Skip to content

Commit

Permalink
Disconnect only if there is a protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 28, 2024
1 parent 9f50c2b commit cebb02f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/postgrex/simple_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,13 @@ defmodule Postgrex.SimpleConnection do
@impl :gen_statem
def handle_event(type, content, statem_state, state)

def handle_event(:internal, {:connect, :reconnect}, @state, %{protocol: protocol} = state) do
def handle_event(:internal, {:connect, :reconnect}, @state, %{protocol: protocol} = state)
when protocol != nil 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
def handle_event(:internal, {:connect, _}, @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 cebb02f

Please sign in to comment.