From 9fbd41b77b0d947fb653f24ddee9f52c389f8122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 7 Oct 2020 16:15:09 +0200 Subject: Add a message_tag to timeout messages sent by cow_http2_machine They are currently optional to avoid doing a breaking change but should become mandatory (perhaps with a default value of undefined) in Cowlib 3.0. --- src/cow_http2_machine.erl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl index a88d9f1..4da7cdf 100644 --- a/src/cow_http2_machine.erl +++ b/src/cow_http2_machine.erl @@ -50,6 +50,7 @@ max_frame_size_received => 16384..16777215, max_frame_size_sent => 16384..16777215 | infinity, max_stream_window_size => 0..16#7fffffff, + message_tag => any(), preface_timeout => timeout(), settings_timeout => timeout(), stream_window_data_threshold => 0..16#7fffffff, @@ -211,6 +212,13 @@ init(server, Opts) -> local_streamid=2 }). +%% @todo In Cowlib 3.0 we should always include MessageTag in the message. +%% It can be set to 'undefined' if the option is missing. +start_timer(Name, Opts=#{message_tag := MessageTag}) -> + case maps:get(Name, Opts, 5000) of + infinity -> undefined; + Timeout -> erlang:start_timer(Timeout, self(), {?MODULE, MessageTag, Name}) + end; start_timer(Name, Opts) -> case maps:get(Name, Opts, 5000) of infinity -> undefined; -- cgit v1.2.3