Skip to content

Commit

Permalink
Avoid orphaning opened connections during emysql:increment_pool_size/2.
Browse files Browse the repository at this point in the history
  • Loading branch information
csrl authored and Henning committed Feb 1, 2012
1 parent 2438031 commit e234672
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/emysql_conn.erl
Expand Up @@ -105,7 +105,15 @@ open_n_connections(PoolId, N) ->
%-% io:format("open ~p connections for pool ~p~n", [N, PoolId]),
case emysql_conn_mgr:find_pool(PoolId, emysql_conn_mgr:pools()) of
{Pool, _} ->
[open_connection(Pool) || _ <- lists:seq(1, N)];
lists:foldl(fun(_ ,Connections) ->
%% Catch {'EXIT',_} errors so newly opened connections are not orphaned.
case catch open_connection(Pool) of
#connection{} = Connection ->
[Connection | Connections];
_ ->
Connections
end
end, [], lists:seq(1, N));
_ ->
exit(pool_not_found)
end.
Expand Down

0 comments on commit e234672

Please sign in to comment.