Skip to content

Commit c5803cf

Browse files
author
Joshua Green
committed
only reconnect if re receive EXIT from the conn pid
1 parent 15c042f commit c5803cf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/pgapp_worker.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ handle_call({transaction, Fun}, _From,
120120
handle_cast(reconnect, State) ->
121121
{noreply, connect(State)}.
122122

123-
handle_info({'EXIT', From, Reason}, State) ->
123+
handle_info({'EXIT', Conn, Reason}, #state{conn=Conn} = State) ->
124124
{NewDelay, Tref} =
125125
case State#state.timer of
126126
undefined ->
@@ -137,9 +137,12 @@ handle_info({'EXIT', From, Reason}, State) ->
137137
end,
138138

139139
error_logger:warning_msg(
140-
"~p EXIT from ~p: ~p - attempting to reconnect in ~p ms~n",
141-
[self(), From, Reason, NewDelay]),
142-
{noreply, State#state{conn = undefined, delay = NewDelay, timer = Tref}}.
140+
"~p EXIT from epgsql_sock ~p: ~p - attempting to reconnect in ~p ms~n",
141+
[self(), Conn, Reason, NewDelay]),
142+
{noreply, State#state{conn = undefined, delay = NewDelay, timer = Tref}};
143+
144+
handle_info(_Other, State) ->
145+
{noreply, State}.
143146

144147
terminate(_Reason, #state{conn = undefined}) ->
145148
ok;

0 commit comments

Comments
 (0)