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

ci: add otp 26 #237

Merged
merged 2 commits into from
Dec 1, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
os:
- macos-12
otp:
- 24
- 25
- 26
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -67,8 +67,8 @@ jobs:
fail-fast: false
matrix:
otp:
- 24.3.4
- 25.3.2
- 26.1.2
openssl:
- openssl3
- openssl
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
fail-fast: false
matrix:
otp:
- 25.3.2-1
- 25.3.2-2
- 26.1.2-1
openssl:
- openssl3
- openssl
Expand Down Expand Up @@ -53,14 +54,11 @@ jobs:
fail-fast: false
matrix:
builder:
- 5.1-3
otp:
- 25.3.2-1
- 5.2-7:1.15.7-25.3.2-2
- 5.2-7:1.15.7-26.1.2-1
openssl:
- openssl3
- openssl
elixir:
- 1.14.5
arch:
- amd64
- arm64
Expand Down Expand Up @@ -99,7 +97,7 @@ jobs:
- name: build release
if: startsWith(github.ref, 'refs/tags/')
run: |
IMAGE=ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
IMAGE=ghcr.io/emqx/emqx-builder/${{ matrix.builder }}-${{ matrix.os }}
docker run -i --rm -v $(pwd):/wd --workdir /wd --platform=linux/${{ matrix.arch }} \
-e BUILD_RELEASE=1 -e QUIC_TLS=${{ matrix.openssl }} \
$IMAGE bash -euc 'git config --global --add safe.directory /wd; make'
Expand Down
16 changes: 8 additions & 8 deletions include/quicer_types.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
, key := file:filename()
, keyfile := file:filename()
, verify => none | peer | verify_peer | verify_none
, cacertfile => filelib:filename()
, cacertfile => file:filename()
, password => string()
, sslkeylogfile => filelib:filename()
, sslkeylogfile => file:filename()
, allow_insecure => boolean()
, quic_registration => reg_handle()
, conn_acceptors => non_neg_integer()
Expand Down Expand Up @@ -141,16 +141,16 @@

-type conn_opts() :: quic_settings() | #{ alpn := [string()]
, conn_callback => module()
, cert => filelib:filename()
, certfile => filelib:filename()
, key => filelib:filename()
, keyfile => filelib:filename()
, cert => file:filename()
, certfile => file:filename()
, key => file:filename()
, keyfile => file:filename()
, password => string()
, verify => none | peer
, handle => connection_handle() %% get NST from last connection, for reconnect.
, nst => binary()
, cacertfile => filelib:filename()
, sslkeylogfile => filelib:filename()
, cacertfile => file:filename()
, sslkeylogfile => file:filename()
, peer_bidi_stream_count => uint16()
, peer_unidi_stream_count => uint16()
, handshake_idle_timeout_ms => non_neg_integer()
Expand Down
55 changes: 33 additions & 22 deletions src/quicer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,19 @@
%% versions
-export([abi_version/0]).

-type connection_opts() :: proplists:proplist() | quicer_connection:opts().
-type listener_opts() :: proplists:proplist() | quicer_listener:listener_opts().

%% export types
-export_type([listener_handle/0,
listener_opts/0,
listen_on/0,
connection_handle/0,
conn_opts/0,
stream_handle/0,
stream_opts/0
]).

-type connection_opts() :: proplists:proplist() | conn_opts().
-type listener_opts() :: proplists:proplist() | listen_opts().

%% @doc Return ABI version of the library.
-spec abi_version() -> quicer_nif:abi_version().
Expand Down Expand Up @@ -161,32 +172,32 @@ close_lib() ->


%% @doc Create a new registration.
-spec new_registration(Name, Profile) ->
quicer_nif:new_registration(Name, Profile).
-spec new_registration(string(), registration_profile()) ->
quicer_nif:new_registration().
new_registration(Name, Profile) ->
quicer_nif:new_registration(Name, Profile).

%% @doc Shutdown a registration.
-spec shutdown_registration(Handle) ->
quicer_nif:shutdown_registration(Handle).
-spec shutdown_registration(reg_handle()) ->
quicer_nif:shutdown_registration().
shutdown_registration(Handle) ->
quicer_nif:shutdown_registration(Handle).

%% @doc Shutdown a registration with error code and silent flag.
-spec shutdown_registration(Handle, IsSilent, ErrCode) ->
quicer_nif:shutdown_registration(Handle, IsSilent, ErrCode).
-spec shutdown_registration(reg_handle(), boolean(), uint64()) ->
quicer_nif:shutdown_registration().
shutdown_registration(Handle, IsSilent, ErrCode) ->
quicer_nif:shutdown_registration(Handle, IsSilent, ErrCode).

%% @doc close a registration.
-spec close_registration(Handle) ->
quicer_nif:close_registration(Handle).
-spec close_registration(reg_handle()) ->
quicer_nif:close_registration().
close_registration(Handle) ->
quicer_nif:close_registration(Handle).

%% @doc get registration name
-spec get_registration_name(Handle) ->
quicer_nif:get_registration_name(Handle).
-spec get_registration_name(reg_handle()) ->
quicer_nif:get_registration_name().
get_registration_name(Handle) ->
quicer_nif:get_registration_name(Handle).

Expand Down Expand Up @@ -288,7 +299,7 @@ listen(ListenOn, Opts) when is_map(Opts) ->
close_listener(Listener) ->
close_listener(Listener, 5000).

-spec close_listener(listener_handle(), timer:time()) ->
-spec close_listener(listener_handle(), timeout()) ->
ok | {error, badarg | closed | timeout}.
close_listener(Listener, Timeout) ->
case quicer_nif:close_listener(Listener) of
Expand Down Expand Up @@ -946,7 +957,7 @@ peername(Handle) ->
%% @doc Peer Cert in DER-encoded binary
%% mimic {@link ssl:peername/1}
-spec peercert(connection_handle() | stream_handle()) ->
{ok, Cert:: public_key:der_encoded()} | {error, any()}.
{ok, CertDerEncoded :: binary()} | {error, any()}.
peercert(Handle) ->
quicer_nif:peercert(Handle).

Expand All @@ -971,15 +982,15 @@ open_connection() ->

%% @doc list all listeners
-spec listeners() -> [{{ quicer_listener:listener_name()
, quicer_listener:listen_on()},
, quicer:listen_on()},
pid()}].
listeners() ->
quicer_listener_sup:listeners().

%% @doc List listener with app name
-spec listener(quicer_listener:listener_name()
| {quicer_listener:listener_name(),
quicer_listener:listen_on()}) -> {ok, pid()} | {error, not_found}.
quicer:listen_on()}) -> {ok, pid()} | {error, not_found}.
listener(Name) ->
quicer_listener_sup:listener(Name).

Expand All @@ -989,7 +1000,7 @@ get_listeners() ->
quicer_nif:get_listeners().

%% @doc Get a list of listeners under registration handle
-spec get_listeners(Reg | global) -> quicer_nif:get_listeners(Reg).
-spec get_listeners(reg_handle() | global) -> quicer_nif:get_listeners().
get_listeners(global) ->
quicer_nif:get_listeners();
get_listeners(Reg) ->
Expand All @@ -1002,21 +1013,21 @@ get_connections() ->
quicer_nif:get_connections().

%% @doc Get a list of connections under registration handle
-spec get_connections(Reg | global) -> quicer_nif:get_connections(Reg).
-spec get_connections(reg_handle() | global) -> quicer_nif:get_connections().
get_connections(global) ->
quicer_nif:get_connections();
get_connections(Reg) ->
quicer_nif:get_connections(Reg).

-spec get_conn_owner(C) -> quicer_nif:get_conn_owner(C).
-spec get_conn_owner(connection_handle()) -> quicer_nif:get_owner().
get_conn_owner(Conn) ->
quicer_nif:get_conn_owner(Conn).

-spec get_stream_owner(S) -> quicer_nif:get_stream_owner(S).
-spec get_stream_owner(stream_handle()) -> quicer_nif:get_owner().
get_stream_owner(Stream) ->
quicer_nif:get_stream_owner(Stream).

-spec get_listener_owner(L) -> quicer_nif:get_listener_owner(L).
-spec get_listener_owner(listener_handle()) -> quicer_nif:get_owner().
get_listener_owner(Listener) ->
quicer_nif:get_listener_owner(Listener).

Expand Down Expand Up @@ -1071,7 +1082,7 @@ handoff_stream(Stream, NewOwner, HandoffData) ->
ActiveN =/= false andalso quicer:setopt(Stream, active, false),
Res = case forward_stream_msgs(Stream, NewOwner) of
ok ->
quicer:controlling_process(Stream, NewOwner),
_ = quicer:controlling_process(Stream, NewOwner),
NewOwner ! {handoff_done, Stream, HandoffData},
ok;
{error, _} = Other ->
Expand Down
2 changes: 1 addition & 1 deletion src/quicer_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]).

start(_StartType, _StartArgs) ->
quicer:open_lib(),
_ = quicer:open_lib(),
_ = quicer:reg_open(application:get_env(quicer, profile, quic_execution_profile_low_latency)),
quicer_sup:start_link().

Expand Down
2 changes: 1 addition & 1 deletion src/quicer_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ start_link(CallbackModule, {_Host, _Port} = Peer, {_COpts, _SOpts} = Opts) when
%% Get `CallbackModule` from conn_opts, key:`conn_callback` if `CallbackModule` is undefined,
%% this is the entry for supervised acceptor.
-spec start_link(CallbackModule :: undefined | module(),
Listener ::quicer:listener_handle(),
Listener :: quicer:listener_handle(),
ConnOpts :: term(),
Sup :: pid()) -> {ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
Expand Down
1 change: 1 addition & 0 deletions src/quicer_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-include("quicer_types.hrl").

-export_type([ cb_ret/0
, cb_state/0
]).
-type cb_ret() :: cb_ret_noreply() | cb_ret_reply().
-type cb_state() :: term().
Expand Down
16 changes: 8 additions & 8 deletions src/quicer_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
, alpn :: [string()]
}).

-export_type([listener_name/0]).

-type listener_name() :: atom().
-type listen_on() :: inet:port_number() | string(). %% "127.0.0.1:8080"
-type listener_opts() :: map().

%%%===================================================================
%%% API
Expand All @@ -47,11 +47,11 @@
%% @end
%%--------------------------------------------------------------------
-spec start_link(Name :: listener_name(),
ListenOn :: listen_on(),
ListenOn :: quicer:listen_on(),
Options ::
{ listener_opts()
, quicer_connection:opts()
, quicer_stream:stream_opts()
{ quicer:listener_opts()
, quicer:conn_opts()
, quicer:stream_opts()
}
) -> {ok, Pid :: pid()} |
{error, Error :: {already_started, pid()}} |
Expand Down Expand Up @@ -89,7 +89,7 @@ init([Name, ListenOn, { #{conn_acceptors := N, alpn := Alpn} = LOpts,
process_flag(trap_exit, true),
{ok, L} = quicer:listen(ListenOn, maps:without([conn_acceptors], LOpts)),
{ok, ConnSup} = supervisor:start_link(quicer_conn_acceptor_sup, [L, Opts]),
[{ok, _} = supervisor:start_child(ConnSup, [ConnSup]) || _ <- lists:seq(1, N)],
_ = [{ok, _} = supervisor:start_child(ConnSup, [ConnSup]) || _ <- lists:seq(1, N)],
{ok, #state{ name = Name
, listener = L
, conn_sup = ConnSup
Expand Down Expand Up @@ -156,5 +156,5 @@ handle_info(_Info, State) ->
State :: term()) -> any().
terminate(_Reason, #state{listener = L}) ->
%% nif listener has no owner process so we need to close it explicitly.
quicer:close_listener(L),
_ = quicer:close_listener(L),
ok.
2 changes: 1 addition & 1 deletion src/quicer_listener_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ start_listener(AppName, Port, Options) ->
supervisor:start_child(?MODULE, chid_spec(AppName, Port, Options)).

stop_listener(AppName) ->
supervisor:terminate_child(?MODULE, ?CHILD_ID(AppName)),
_ = supervisor:terminate_child(?MODULE, ?CHILD_ID(AppName)),
supervisor:delete_child(?MODULE, ?CHILD_ID(AppName)).

-spec listeners() -> [{{atom(), integer()|string()}, pid()}].
Expand Down
Loading