Skip to content

Commit

Permalink
Merge pull request #275 from qzhuyan/fix-quic-enabling
Browse files Browse the repository at this point in the history
fix: re-enable no-quic build
  • Loading branch information
qzhuyan authored Dec 18, 2024
2 parents ad9cbaf + 9eb235f commit 265f519
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- 1.15.7
quic_support:
- true
- false
os:
- ubuntu22.04
- ubuntu20.04
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# emqtt-bench changelog
## 0.4.28
* release: fix and re-enable no-quic build

## 0.4.27

Expand Down
30 changes: 17 additions & 13 deletions src/emqtt_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ main(conn, Opts) ->
start(conn, Opts).

start(PubSub, Opts) ->
ets:new(qoe_store, [named_table, public, ordered_set]),
prepare(PubSub, Opts), init(),
prepare(PubSub, Opts),
init(),
maybe_init_prometheus(lists:member(prometheus, Opts)),
maybe_start_restapi(proplists:get_value(restapi, Opts)),
IfAddr = proplists:get_value(ifaddr, Opts),
Expand Down Expand Up @@ -473,17 +473,12 @@ prepare(PubSub, Opts) ->
false ->
ok
end,
case is_quic(Opts) of
true ->
maybe_start_quicer() orelse error({quic, not_supp_or_disabled}),
prepare_for_quic(Opts);
_ ->
ok
end,
prepare_quicer(Opts),
application:ensure_all_started(emqtt_bench).

init() ->
process_flag(trap_exit, true),
ets:new(qoe_store, [named_table, public, ordered_set]),
Now = erlang:monotonic_time(millisecond),
Counters = counters(),
CRef = counters:new(length(Counters)+1, [write_concurrency]),
Expand Down Expand Up @@ -1342,8 +1337,8 @@ percentile(Input, P) ->
Pos = ceil(Len * P),
lists:nth(Pos, lists:sort(Input)).

-spec prepare_for_quic(proplists:proplist()) -> ok | skip.
prepare_for_quic(Opts)->
-spec prepare_quic_nst(proplists:proplist()) -> ok | skip.
prepare_quic_nst(Opts)->
%% Create ets table for 0-RTT session tickets
ets:new(quic_clients_nsts, [named_table, public, ordered_set,
{write_concurrency, true},
Expand Down Expand Up @@ -1617,10 +1612,10 @@ maybe_prefix_payload(Payload, ClientOpts) ->

-spec is_quic(proplists:proplist()) -> boolean().
is_quic(Opts) ->
proplists:get_value(quic, Opts, false) =/= false.
proplists:get_value(quic, Opts) =/= false.

quic_opts_from_arg(Opts)->
case proplists:get_value(quic, Opts, false) of
case proplists:get_value(quic, Opts) of
V when is_boolean(V) ->
V;
"false" ->
Expand All @@ -1640,3 +1635,12 @@ quic_opts_from_arg(Opts)->
error("bad --quic")
end
end.

prepare_quicer(Opts) ->
case quic_opts_from_arg(Opts) =/= false of
true ->
maybe_start_quicer() orelse error({quic, not_supp_or_disabled}),
prepare_quic_nst(Opts);
_ ->
ok
end.

0 comments on commit 265f519

Please sign in to comment.