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

Advance resource management #320

Merged
merged 19 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .github/workflows/hex_pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
- '*'

jobs:
if: false
publish:
if: false
runs-on: ubuntu-latest
steps:
- name: Check out
Expand Down
40 changes: 36 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,41 @@ jobs:
run: |
rebar3 fmt -c

mac:
timeout-minutes: 60
pre-check:
name: Pre check
needs: formatting-check
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
# https://builds.hex.pm/builds/otp/ubuntu-22.04/builds.txt
otp:
- 26.2.5.3
rebar3:
- 3.23.0
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive
- uses: erlef/setup-beam@2f0cc07b4b9bea248ae098aba9e1a8a1de5ec24c # v1.17.5
with:
otp-version: ${{ matrix.otp }}
rebar3-version: ${{ matrix.rebar3 }}
- name: release build with debug log off
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=Debug
export QUICER_TLS_VER=sys
make ci

mac-mesh:
timeout-minutes: 60
needs: pre-check
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -78,8 +110,8 @@ jobs:
retention-days: 1


linux:
needs: formatting-check
linux-mesh:
needs: pre-check
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
Expand Down
33 changes: 11 additions & 22 deletions c_src/quicer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
#include "quicer_tls.h"
#include <msquichelper.h>

extern QuicerRegistrationCTX *G_r_ctx;
extern QuicerRegistrationCTX G_r_ctx;
extern pthread_mutex_t MsQuicLock;

static ERL_NIF_TERM get_stream_opt(ErlNifEnv *env,
Expand Down Expand Up @@ -218,11 +218,6 @@ ServerLoadConfiguration(ErlNifEnv *env,
{
QUIC_SETTINGS Settings = { 0 };

if (!G_r_ctx)
{
return ATOM_REG_FAILED;
}

if (!create_settings(env, option, &Settings))
{
return ATOM_BADARG;
Expand Down Expand Up @@ -275,11 +270,6 @@ ClientLoadConfiguration(ErlNifEnv *env,
QUIC_SETTINGS Settings = { 0 };
ERL_NIF_TERM ret = ATOM_OK;

if (!G_r_ctx)
{
return ATOM_REG_FAILED;
}

//
// Configures the client's idle timeout.
//
Expand Down Expand Up @@ -1344,7 +1334,7 @@ get_stream_opt(ErlNifEnv *env,
{
res = get_level_param(env,
s_ctx->Stream,
s_ctx->c_ctx->config_resource->Configuration,
s_ctx->c_ctx->config_ctx->Configuration,
optname,
elevel);
goto Exit;
Expand Down Expand Up @@ -1458,7 +1448,7 @@ set_stream_opt(ErlNifEnv *env,
{
res = set_level_param(env,
s_ctx->Stream,
s_ctx->c_ctx->config_resource->Configuration,
s_ctx->c_ctx->config_ctx->Configuration,
optname,
optval,
elevel);
Expand Down Expand Up @@ -1531,13 +1521,13 @@ get_connection_opt(ErlNifEnv *env,

if (!IS_SAME_TERM(ATOM_FALSE, elevel))
{
if (!c_ctx->config_resource)
if (!c_ctx->config_ctx)
{
goto Exit;
}
res = get_level_param(env,
c_ctx->Connection,
c_ctx->config_resource->Configuration,
c_ctx->config_ctx->Configuration,
optname,
elevel);
goto Exit;
Expand Down Expand Up @@ -1724,13 +1714,13 @@ set_connection_opt(ErlNifEnv *env,

if (!IS_SAME_TERM(ATOM_FALSE, elevel))
{
if (!c_ctx->config_resource)
if (!c_ctx->config_ctx)
{
goto Exit;
}
res = set_level_param(env,
c_ctx->Connection,
c_ctx->config_resource->Configuration,
c_ctx->config_ctx->Configuration,
optname,
optval,
elevel);
Expand Down Expand Up @@ -2062,13 +2052,13 @@ get_listener_opt(ErlNifEnv *env,
{
return ERROR_TUPLE_2(ATOM_CLOSED);
}
enif_keep_resource(l_ctx);
get_listener_handle(l_ctx);

if (!IS_SAME_TERM(ATOM_FALSE, elevel))
{
res = get_level_param(env,
l_ctx->Listener,
l_ctx->config_resource->Configuration,
l_ctx->config_ctx->Configuration,
optname,
elevel);
goto Exit;
Expand Down Expand Up @@ -2123,7 +2113,7 @@ get_listener_opt(ErlNifEnv *env,
res = ERROR_TUPLE_2(ATOM_STATUS(status));
}
Exit:
enif_release_resource(l_ctx);
put_listener_handle(l_ctx);
return res;
}

Expand Down Expand Up @@ -2157,7 +2147,7 @@ set_listener_opt(ErlNifEnv *env,
{
res = set_level_param(env,
l_ctx->Listener,
l_ctx->config_resource->Configuration,
l_ctx->config_ctx->Configuration,
optname,
optval,
elevel);
Expand Down Expand Up @@ -2644,7 +2634,6 @@ parse_registration(ErlNifEnv *env,
return FALSE;
}
}

return TRUE;
}

Expand Down
Loading
Loading