Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SBS 17.02.01 008549, 008550, 008551] killing session properly #15

Merged
merged 4 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/erlocipool_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ handle_cast({kill, #session{
try
true = demonitor(OciMon, [flush]),
OciPort = {oci_port, PortPid},
ok = OciPort:close()
OciPort:close()
catch
_:Reason ->
?DBG("handle_cast(kill)", "error ~p~n~p",
Expand Down Expand Up @@ -218,7 +218,7 @@ handle_cast({check, {PortPid, OciSessnHandle, _OciStmtHandle}}, State) ->
%?DBG("OciSession:ping()", "session ~p",
% [{PortPid, OciSessnHandle}]),
case catch OciSession:ping() of
ok -> ok;
pong -> ok;
_Error ->
kill(Self, PortPid, OciSessnHandle,
State#state.sessions)
Expand All @@ -230,10 +230,9 @@ handle_cast(_Request, State) ->

handle_info({check_reduce, ToClose},
#state{sessions =
[#session{ssn = OciSession,
openStmts = 0} | Sessions]} = State)
[#session{openStmts = 0} = Session | Sessions]} = State)
when ToClose > 0 ->
gen_server:cast(self(), {kill, OciSession}),
gen_server:cast(self(), {kill, Session}),
self() ! {check_reduce, ToClose - 1},
{noreply, State#state{sessions = sort_sessions(Sessions)}};
handle_info({check_reduce, _}, State) ->
Expand Down
2 changes: 0 additions & 2 deletions test/erlocipool_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ bad_conn_recover({Pool, _OciPort, OciSession, SessBefore}) ->
?assertMatch({error, _}, S:exec_stmt()),
%% Pool replenished with new sessions
?assertMatch([#{closed_stmts := 0, open_stmts := 0},
#{closed_stmts := 0, open_stmts := 0},
#{closed_stmts := 0, open_stmts := 0},
#{closed_stmts := 0, open_stmts := 0}], Pool:get_stats()).

%------------------------
Expand Down