Skip to content

Commit

Permalink
Restore compatibility with older OTP releases
Browse files Browse the repository at this point in the history
Support is ensured for OTP-24 but it should also still work for older
releases (not guaranteed).
  • Loading branch information
Tobias Schlager committed Sep 13, 2024
1 parent 21c1127 commit 7ef7142
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp: [25, 26, 27]
otp: [24, 25, 26, 27]
container:
image: erlang:${{ matrix.otp }}
steps:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ History

### Master (4.0.1)

Currently no difference to latest tag.
* Enhance performance of session lookups (thanks to @IslandUsurper)
* Drop (official) support for OTP releases older than 24.3 (currently it should
still work with older versions)

### Version 4.0.0

Expand Down
20 changes: 9 additions & 11 deletions src/eipmi.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%%=============================================================================
%%% Copyright (c) 2012-2019 Lindenbaum GmbH
%%% Copyright (c) 2012-2024 Lindenbaum GmbH
%%%
%%% Permission to use, copy, modify, and/or distribute this software for any
%%% purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -1145,10 +1145,8 @@ poll_sel(Session) ->
poll_sel(Session = {session, Target, _}, Interval, Clear) when Interval > 0 ->
Result =
case ets:lookup(eipmi_sessions, {session, Target}) of
[{_, Pid, _}] ->
{ok, Pid};
[] ->
{error, no_session}
[{_, Pid, _}] -> {ok, Pid};
[] -> {error, no_session}
end,
poll_sel(Result, Session, Interval, Clear).
poll_sel({ok, Pid}, Session, Interval, Clear) ->
Expand Down Expand Up @@ -1554,12 +1552,12 @@ stop(_State) -> ok.
%% @private
%%------------------------------------------------------------------------------
init([]) ->
ets:new(eipmi_sessions, [
named_table,
public,
{write_concurrency, auto},
{read_concurrency, true}
]),
EtsOptions = [named_table, public, {read_concurrency, true}],
try
ets:new(eipmi_sessions, [{write_concurrency, auto} | EtsOptions])
catch
error:badarg -> ets:new(eipmi_sessions, EtsOptions)
end,
TrapPorts = application:get_env(?MODULE, trap_ports, []),
{ok, {{one_for_one, 5, 1000}, [trap_spec(Port) || Port <- TrapPorts]}}.

Expand Down

0 comments on commit 7ef7142

Please sign in to comment.