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

Dev/william/msquic 2.2 #212

Merged
merged 6 commits into from
Sep 18, 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
21 changes: 14 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ jobs:
otp:
- 24.3.4
- 25.3.2
openssl:
- openssl3
- openssl
rebar3:
- 3.20.0
build_type:
- RelWithDebInfo
- Debug
logging:
- true
- false
- ON
- OFF
arch:
- x86_64
steps:
Expand All @@ -88,16 +91,20 @@ jobs:
otp-version: ${{ matrix.otp }}
rebar3-version: ${{ matrix.rebar3 }}
- name: release build with debug log off
env:
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
QUIC_TLS: ${{ matrix.openssl }}
QUIC_ENABLE_LOGGING: ${{ matrix.logging }}
run: |
echo "github ref: ${{ github.event.ref }}"
echo "github ref: ${{ github.ref }}"
sudo sysctl -w kernel.core_pattern=core
ulimit -c unlimited
export CMAKE_BUILD_TYPE=${{ matrix.build_type }}

if ${{ matrix.logging }}"" == "true" ; then
export QUIC_ENABLE_LOGGING=ON

export CMAKE_BUILD_TYPE
export QUIC_TLS
export QUIC_ENABLE_LOGGING
if [ "${QUIC_ENABLE_LOGGING}" == "ON" ] ; then
export QUIC_LOGGING_TYPE=lttng
sudo apt-add-repository ppa:lttng/stable-2.13
sudo apt-get update
sudo apt-get install -y lttng-tools babeltrace liblttng-ust-dev lttng-modules-dkms-
Expand Down
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ else()
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

if (DEFINED ENV{QUICER_USE_OPENSSL3})
message(STATUS "Use openssl3")
set(QUIC_TLS "openssl3")
endif()

if (DEFINED ENV{QUIC_ENABLE_LOGGING})
set(QUIC_ENABLE_LOGGING $ENV{QUIC_ENABLE_LOGGING})
set(QUIC_LOGGING_TYPE lttng)
else()
set(QUIC_ENABLE_LOGGING "OFF")
endif()

if (DEFINED ENV{QUIC_LOGGING_TYPE})
set(QUIC_ENABLE_LOGGING "ON")
paulozulato marked this conversation as resolved.
Show resolved Hide resolved
set(QUIC_LOGGING_TYPE $ENV{QUIC_LOGGING_TYPE})
endif()

if (DEFINED ENV{QUICER_USE_LTTNG} AND DEFINED ENV{QUICER_USE_SNK})
message(FATAL_ERROR "QUICER_USE_LTTNG and QUICER_USE_SNK cannot be defined at same time")
endif()
Expand Down Expand Up @@ -91,8 +102,8 @@ add_subdirectory(msquic)
add_library(quicer_static STATIC ${SOURCES})
target_include_directories(quicer_static PRIVATE ${Erlang_OTP_ROOT_DIR}/usr/include/ msquic/src/inc/)
if (CMAKE_SYSTEM_NAME MATCHES Linux)
# note, the value of ${ATOMIC} will be set by msquic
target_link_libraries(quicer_static PRIVATE core platform inc warnings logging ${ATOMIC} "-Wl,--no-gc-sections")
# note, the value of ${ATOMIC} and %{NUMA} will be set by msquic
target_link_libraries(quicer_static PRIVATE core platform inc warnings logging ${ATOMIC} ${NUMA} "-Wl,--no-gc-sections")
elseif (CMAKE_SYSTEM_NAME MATCHES Darwin)
target_link_libraries(quicer_static PRIVATE core platform inc warnings "-Wl,-undefined,dynamic_lookup -Wl,-dead_strip")
endif()
Expand Down Expand Up @@ -125,7 +136,7 @@ set_target_properties(quicer_nif
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/priv/
)

if (QUIC_ENABLE_LOGGING)
if (QUIC_ENABLE_LOGGING STREQUAL "ON" AND QUIC_LOGGING_TYPE STREQUAL "lttng")
set_target_properties(msquic.lttng PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/priv)
set_target_properties(msquic.lttng PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/priv)
endif()
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default: build-nif

.PHONY: build-nif
build-nif:
./build.sh 'v2.1.8'
./build.sh 'v2.2.2'

compile:
$(REBAR) compile
Expand Down
24 changes: 14 additions & 10 deletions test/quicer_listener_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ tc_open_listener(Config) ->
{ok, {_, Port}} = quicer:sockname(L),
{error, eaddrinuse} = gen_udp:open(Port),
ok = quicer:close_listener(L),
{ok, P} = gen_udp:open(Port),
{ok, P} = snabbkaffe:retry(100, 10, fun()-> {ok, _} = gen_udp:open(Port) end),
ok = gen_udp:close(P),
ok.

Expand All @@ -224,7 +224,7 @@ tc_open_listener_with_new_reg(Config) ->
%% Then Listener is created successfully and port is occupied
{error, eaddrinuse} = gen_udp:open(Port),
ok = quicer:close_listener(L),
{ok, P} = gen_udp:open(Port),
{ok, P} = snabbkaffe:retry(100, 10, fun()-> {ok, _} = gen_udp:open(Port) end),
ok = gen_udp:close(P),
ok = quicer:shutdown_registration(Reg),
ok.
Expand All @@ -251,22 +251,24 @@ tc_open_listener_with_wrong_cert_password(Config) ->
, quicer:listen(Port, default_listen_opts(PasswordCerts ++ Config))).

tc_open_listener_bind(Config) ->
ListenOn = "127.0.0.1:4567",
Port = select_port(),
ListenOn = "127.0.0.1"++":"++integer_to_list(Port),
{ok, L} = quicer:listen(ListenOn, default_listen_opts(Config)),
{ok, {_, _}} = quicer:sockname(L),
{error,eaddrinuse} = gen_udp:open(4567),
{error, eaddrinuse} = gen_udp:open(Port),
ok = quicer:close_listener(L),
{ok, P} = gen_udp:open(4567),
{ok, P} = snabbkaffe:retry(100, 10, fun() -> {ok, _} = gen_udp:open(Port) end),
ok = gen_udp:close(P),
ok.

tc_open_listener_bind_v6(Config) ->
ListenOn = "[::1]:4567",
Port = select_port(),
ListenOn = "[::1]"++":"++integer_to_list(Port),
{ok, L} = quicer:listen(ListenOn, default_listen_opts(Config)),
{ok, {_, _}} = quicer:sockname(L),
{error,eaddrinuse} = gen_udp:open(4567, [{ip, {0, 0, 0, 0, 0, 0, 0, 1}}]),
{error, eaddrinuse} = gen_udp:open(Port, [{ip, {0, 0, 0, 0, 0, 0, 0, 1}}]),
ok = quicer:close_listener(L),
{ok, P} = gen_udp:open(4567, [{ip, {0, 0, 0, 0, 0, 0, 0, 1}}]),
{ok, P} = snabbkaffe:retry(100, 10, fun() -> {ok, _} = gen_udp:open(Port, [{ip, {0, 0, 0, 0, 0, 0, 0, 1}}]) end),
ok = gen_udp:close(P),
ok.

Expand Down Expand Up @@ -325,7 +327,7 @@ tc_stop_start_listener(Config) ->
LConf = default_listen_opts(Config),
{ok, L} = quicer:listen(Port, LConf),
ok = quicer:stop_listener(L),
ok = quicer:start_listener(L, Port, LConf),
ok = snabbkaffe:retry(100, 10, fun() -> ok = quicer:start_listener(L, Port, LConf) end),
ok = quicer:close_listener(L).

tc_stop_close_listener(Config) ->
Expand Down Expand Up @@ -465,7 +467,9 @@ tc_listener_stopped_when_owner_die(Config) ->
ok = quicer:close_listener(L1).

select_port() ->
select_free_port(quic).
Port = select_free_port(quic),
timer:sleep(100),
Port.

%%%_* Emacs ====================================================================
%%% Local Variables:
Expand Down
10 changes: 8 additions & 2 deletions test/quicer_snb_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1701,16 +1701,22 @@ tc_conn_stop_notify_acceptor(Config) ->
ct:pal("Listener Options: ~p", [Options]),
?check_trace(#{timetrap => 10000},
begin
{ok, Listener} = quicer:listen(Port, ListenerOpts),
Parent = self(),
{SPid, Ref} = spawn_monitor(fun() ->
{ok, Listener} = quicer:listen(Port, ListenerOpts),
Parent ! {self(), ready},
{ok, Conn} = quicer:accept(Listener, []),
Acceptors = lists:map(fun(_) ->
spawn(quicer, accept_stream, [Conn, []])
end, lists:seq(1, 100)),
{ok, Conn} = quicer:handshake(Conn),
{error, closed} = quicer:accept_stream(Conn, []),
case quicer:accept_stream(Conn, []) of
{error, closed} -> ok;
{ok, _Stream} -> ok
end,
exit({normal, Acceptors})
end),
receive {SPid, ready} -> ok end,
{ok, Conn} = quicer:connect("localhost", Port, default_conn_opts(), infinity),
quicer:shutdown_connection(Conn),

Expand Down