Skip to content

Commit

Permalink
Merge pull request #234 from qzhuyan/dev/william/fix-build
Browse files Browse the repository at this point in the history
fix(build): remove workaround for emqx
  • Loading branch information
qzhuyan authored Nov 27, 2023
2 parents 9dbb916 + 07e6ff0 commit bbe8831
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 73 deletions.
6 changes: 0 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,3 @@ else
fi
fi

## workaround for emqx forked rebar3
if ([ -n $REBAR_DEPS_DIR ] && [ $(realpath -P "${REBAR_DEPS_DIR}/quicer/priv") != "${PWD}/priv" ]);
then
cp -r priv/* "${REBAR_DEPS_DIR}/quicer/priv/"
cp include/quicer_vsn.hrl "${REBAR_DEPS_DIR}/quicer/include/"
fi
1 change: 0 additions & 1 deletion c_src/quicer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,6 @@ get_conn_owner1(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
goto exit;
}
res = SUCCESS(enif_make_pid(env, &(c_ctx->owner->Pid)));
;
exit:
enif_mutex_unlock(c_ctx->lock);
return res;
Expand Down
46 changes: 1 addition & 45 deletions docs/DesignDecisions.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,12 @@
# Design Decisions

This doc contains design decisions we have made and provides some insights about background and reasons
For each decision.
for each decision.

If you don't agree with the decision or causing issue, please refer to the chapter number in the issue report.

# Decisions

## Resources Managements

1. Connection or Stream should not cross references
For example, in `s_ctx` it should not have a field `c_ctx`, because stream callback can still get called
While the `connection` in `c_ctx` is closed due to a close call, is asynchronous.

To avoid getting access to an invalid handle (already closed), there should be no cross references among these resources.

Access to invalid handles could lead to undefined behavior in MsQuic that includes segfault or abort due to assertions.

However, keep ref counting is still required to avoid the MsQuic handle getting closed too early (it is still in use).

1. MsQuic handle
All MsQuic handles should be only closed in resource dealloc callback.

For tracking resources usage, quicer do not do refcnt on MsQuic handles, instead it relies on the Erlang garbage
Collection mechanism to track the refcnt on the MsQuic handle.

To inc refcnt use:

``` c

enif_make_resource

// OR

enif_keep_resource


```


To dec refcnt use:

`enif_release_resource`

*CONS*
- The resources are not closed/freed until the GC kicks in, that means the releasing resources will be delayed.

This behavior also aligns with the delayed GC in BEAM.

- It also requires in the Erlang process not to keep the unused/closed resources in the stack/heap,
otherwise it will cause memory leaks.

## Send message to the owner

1. Messages with boxed types are copied to the owner's mailbox.
18 changes: 0 additions & 18 deletions docs/todo.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,25 @@

Feature todo list, priority descending

** Notify acceptors when listener is closed.

** Stream behavior should able to handle multiple streams
One process could become the owner of multiple streams in the scenario
that these streams are correlated.

** Impl ConfigurationLoadCredential
Load QUIC_CREDENTIAL_CONFIG to configuration

** quicer_stream proc should able to handle more streams

** Close configurations in resource destroy callback

** Check shutdown connection wait for peer to close or not

** DONE Hibernate connection owner process since connection process is mostly idling
Doable via return value of callback fun.

** Get/Set Context
with lock protection set/get the callback context.

** New API: open_send(connection_handle(), Data, Flags)
Open stream over this connection and send without starting the stream

** RegistrationShutdown
API for registrationshutdown, shutdown all connections under registration

** Unintentional Transport Migration

** NIF Segfault recover

** Different Application Profile (low latency, high throughput)

** NIF Upgrade

* Improvements
Expand All @@ -62,10 +48,6 @@ API for registrationshutdown, shutdown all connections under registration

- check types.

- refactor DATAGRAM handling

- Report StreamID in event: `new_stream`

- Level of APIs

Current API are designd to easily migrate from TCP.
Expand Down
23 changes: 21 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[{"(linux|darwin|solaris)", compile, "make build-nif"}
]}.

{deps, [{snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.9"}}}
{deps, [{snabbkaffe, "1.0.9"}
]}.

{profiles,
Expand Down Expand Up @@ -41,11 +41,30 @@
{extended_start_script, true}]}.



{project_plugins, [{coveralls, {git, "https://github.com/qzhuyan/coveralls-erl", {branch, "qzhuyan"}}}
, rebar3_hex
, rebar3_ex_doc
]}.

%% Coveralls
{project_plugins, [{coveralls, {git, "https://github.com/qzhuyan/coveralls-erl", {branch, "qzhuyan"}}}]}.
{cover_enabled, true}.
{cover_excl_mods, [qt, qt_ssl, rev, user_default]}.
{cover_export_enabled, true}.
{coveralls_coverdata, "_build/test/cover/*.coverdata"}. % or a string with wildcards or a list of files
{coveralls_service_name, "github"}.
{coveralls_parallel, true}.


%% HEX publish
{hex, [{doc, ex_doc}]}.
{ex_doc, [
{extras, [ "README.md"
, "LICENSE"
, "docs/messages_to_owner.md"
, "docs/Terminology.md"
, "docs/DesignDecisions.md"
]},
{main, "README.md"},
{source_url, "https://github.com/emqx/quic"}
]}.
2 changes: 1 addition & 1 deletion src/quicer.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
, quicer_sup
, quicer_nif]},

{licenses, ["Apache 2.0"]},
{licenses, ["Apache-2.0"]},
{links, [{"Github", "https://github.com/emqx/quic"}]},
{include_files, [ "CMakeLists.txt"
, "Makefile"
Expand Down

0 comments on commit bbe8831

Please sign in to comment.