From db1d10c44b664f1056d1359362ba13dde283353a Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 31 Mar 2021 13:45:40 +0200 Subject: [PATCH] feat(quic): handle stream close. --- etc/emqx.conf | 4 ++-- rebar.config | 2 +- src/emqx_connection.erl | 3 +++ src/emqx_quic_stream.erl | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index c512ec9f8..fdc30d206 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -2080,8 +2080,8 @@ listener.wss.external.check_origins = https://localhost:8084, https://127.0.0.1: ## ## Value: IP:Port | Port ## -## Examples: 8084, 127.0.0.1:8084, ::1:8084 -listener.quic.external = 4567 +## Examples: 14567, 127.0.0.1:14567, ::1:14567 +listener.quic.external = 14567 ## The path of WebSocket MQTT endpoint ## diff --git a/rebar.config b/rebar.config index d78644bf9..b0a38ebf5 100644 --- a/rebar.config +++ b/rebar.config @@ -52,7 +52,7 @@ , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1 , {getopt, "1.0.1"} - , {quicer, {git, "https://github.com/qzhuyan/quic.git", {branch, "quicer_application"}}} + , {quicer, {git, "https://github.com/qzhuyan/quic.git", {branch, "fix/getopt3-free-bin"}}} ]}. {xref_ignores, diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index d46184fbd..60dcd06e8 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -657,6 +657,9 @@ handle_info({sock_error, Reason}, State) -> Reason =/= closed andalso ?LOG(error, "Socket error: ~p", [Reason]), handle_info({sock_closed, Reason}, close_socket(State)); +handle_info({quic, closed, _Channel, ReasonFlag}, State) -> + handle_info({sock_closed, ReasonFlag}, State); + handle_info(Info, State) -> with_channel(handle_info, [Info], State). diff --git a/src/emqx_quic_stream.erl b/src/emqx_quic_stream.erl index e12d95f30..a80af643a 100644 --- a/src/emqx_quic_stream.erl +++ b/src/emqx_quic_stream.erl @@ -62,7 +62,9 @@ getopts(_Socket, _Opts) -> {buffer,80000}]}. fast_close(Stream) -> - quicer:close_stream(Stream). + quicer:close_stream(Stream), + %% Stream might be closed already. + ok. -spec(ensure_ok_or_exit(atom(), list(term())) -> term()). ensure_ok_or_exit(Fun, Args = [Sock|_]) when is_atom(Fun), is_list(Args) ->