From 4d6ebbfc569c30eebe38311b47166e4cf6aac6e7 Mon Sep 17 00:00:00 2001 From: Joshua Green Date: Fri, 14 Dec 2018 10:26:47 +0100 Subject: [PATCH] only reconnect if we receive EXIT from the conn pid --- src/pgapp_worker.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pgapp_worker.erl b/src/pgapp_worker.erl index 5684498..b71c051 100644 --- a/src/pgapp_worker.erl +++ b/src/pgapp_worker.erl @@ -120,7 +120,7 @@ handle_call({transaction, Fun}, _From, handle_cast(reconnect, State) -> {noreply, connect(State)}. -handle_info({'EXIT', From, Reason}, State) -> +handle_info({'EXIT', Conn, Reason}, #state{conn=Conn} = State) -> {NewDelay, Tref} = case State#state.timer of undefined -> @@ -137,9 +137,12 @@ handle_info({'EXIT', From, Reason}, State) -> end, error_logger:warning_msg( - "~p EXIT from ~p: ~p - attempting to reconnect in ~p ms~n", - [self(), From, Reason, NewDelay]), - {noreply, State#state{conn = undefined, delay = NewDelay, timer = Tref}}. + "~p EXIT from epgsql_sock ~p: ~p - attempting to reconnect in ~p ms~n", + [self(), Conn, Reason, NewDelay]), + {noreply, State#state{conn = undefined, delay = NewDelay, timer = Tref}}; + +handle_info(_Other, State) -> + {noreply, State}. terminate(_Reason, #state{conn = undefined}) -> ok;