aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-10-07 16:15:09 +0200
committerLoïc Hoguin <[email protected]>2020-10-07 16:15:09 +0200
commit9fbd41b77b0d947fb653f24ddee9f52c389f8122 (patch)
treef196043135b8f9a4f20bc4532e47dfa26acb2bf5
parent37217f63bedc91d3c316139c234b0a80107f5208 (diff)
downloadcowlib-9fbd41b77b0d947fb653f24ddee9f52c389f8122.tar.gz
cowlib-9fbd41b77b0d947fb653f24ddee9f52c389f8122.tar.bz2
cowlib-9fbd41b77b0d947fb653f24ddee9f52c389f8122.zip
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.
-rw-r--r--src/cow_http2_machine.erl8
1 files changed, 8 insertions, 0 deletions
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;