diff options
-rw-r--r-- | src/cow_http2_machine.erl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl index 4e57c04..794598a 100644 --- a/src/cow_http2_machine.erl +++ b/src/cow_http2_machine.erl @@ -15,6 +15,7 @@ -module(cow_http2_machine). -export([init/2]). +-export([terminate/1]). -export([init_stream/2]). -export([init_upgrade_stream/2]). -export([frame/2]). @@ -258,6 +259,17 @@ setting_from_opt(Settings, Opts, OptName, SettingName, Default) -> Value -> Settings#{SettingName => Value} end. +-spec terminate(State::http2_machine()) -> ok. +terminate(#http2_machine{preface_timer=PTRef, settings_timer=STRef}) -> + case PTRef of + undefined -> ok; + _ -> erlang:cancel_timer(PTRef, [{async, true}, {info, false}]) + end, + case STRef of + undefined -> ok; + _ -> erlang:cancel_timer(STRef, [{async, true}, {info, false}]) + end. + -spec init_stream(binary(), State) -> {ok, cow_http2:streamid(), State} when State::http2_machine(). init_stream(Method, State=#http2_machine{mode=client, local_streamid=LocalStreamID, @@ -996,11 +1008,11 @@ ignored_frame(State) -> timeout(preface_timeout, TRef, State=#http2_machine{preface_timer=TRef}) -> {error, {connection_error, protocol_error, 'The preface was not received in a reasonable amount of time.'}, - State}; + State#http2_machine{preface_timer=undefined}}; timeout(settings_timeout, TRef, State=#http2_machine{settings_timer=TRef}) -> {error, {connection_error, settings_timeout, 'The SETTINGS ack was not received within the configured time. (RFC7540 6.5.3)'}, - State}; + State#http2_machine{settings_timer=undefined}}; timeout(_, _, State) -> {ok, State}. |