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

LB feature in msquic2.3.5 #286

Merged
merged 2 commits into from
May 22, 2024
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: 17 additions & 4 deletions c_src/quicer_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,14 +1148,14 @@ on_unload(__unused_parm__ ErlNifEnv *env, __unused_parm__ void *priv_data)
}

static ERL_NIF_TERM
openLib(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])
openLib(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
assert(1 == argc);
CXPLAT_FRE_ASSERT(argc == 1);
TP_NIF_3(enter, 0, 1);
QUIC_STATUS status = QUIC_STATUS_SUCCESS;
ERL_NIF_TERM res = ATOM_FALSE;
ERL_NIF_TERM lttngLib = argv[0];
char lttngPath[PATH_MAX] = { 0 };
unsigned int lb_mode = 0;

pthread_mutex_lock(&MsQuicLock);
if (MsQuic)
Expand All @@ -1180,7 +1180,20 @@ openLib(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])

res = SUCCESS(ATOM_TRUE);

if (enif_get_string(env, lttngLib, lttngPath, PATH_MAX, ERL_NIF_LATIN1))
ERL_NIF_TERM eterm = ATOM_UNDEFINED;

if (enif_get_map_value(
env, argv[0], ATOM_QUIC_PARAM_GLOBAL_LOAD_BALACING_MODE, &eterm)
&& enif_get_uint(env, eterm, &lb_mode))
{
MsQuic->SetParam(NULL,
QUIC_PARAM_GLOBAL_LOAD_BALACING_MODE,
sizeof(uint16_t),
(uint16_t *)&lb_mode);
}

if (enif_get_map_value(env, argv[0], ATOM_TRACE, &eterm)
&& enif_get_string(env, eterm, lttngPath, PATH_MAX, ERL_NIF_LATIN1))
{
// loading lttng lib is optional, ok to fail
if (dlopen(lttngPath, (unsigned)RTLD_NOW | (unsigned)RTLD_GLOBAL))
Expand Down
2 changes: 1 addition & 1 deletion src/quicer.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
stdlib
]},
{mod, {quicer_app, []}},
{env, []},
{env, [{lb_mode, 0}]},
{modules, [
quicer,
quicer_app,
Expand Down
5 changes: 4 additions & 1 deletion src/quicer_nif.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ open_lib() ->
{error, _} ->
priv_dir()
end,
open_lib(LibFile).
open_lib(#{
load_balacing_mode => application:get_env(quicer, lb_mode, 0),
trace => LibFile
}).

open_lib(_LttngLib) ->
erlang:nif_error(nif_library_not_loaded).
Expand Down
Loading