diff options
author | Bartek Walkowicz <[email protected]> | 2018-03-01 14:49:57 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-03-14 17:15:06 +0100 |
commit | 21317093285190f854acaf223db2e08f79069757 (patch) | |
tree | e234a0e8e32b39f87bdfc2282b09611d71a55fc8 /src/cowboy_http.erl | |
parent | f9092126fafe063513444ca2b3c2aec6af14ed7b (diff) | |
download | cowboy-21317093285190f854acaf223db2e08f79069757.tar.gz cowboy-21317093285190f854acaf223db2e08f79069757.tar.bz2 cowboy-21317093285190f854acaf223db2e08f79069757.zip |
Add case for handling infinity for idle/request_timeout
Currently cowboy assumes that idle_timeout or request_timeout is
a number and always starts timers. Similar situation takes place
in case of preface_timeout for http2. This commit adds case for
handling infinity as a timeout, allowing to not start mentioned
timers.
Diffstat (limited to 'src/cowboy_http.erl')
-rw-r--r-- | src/cowboy_http.erl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index 6a75a1a..2f30279 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -222,8 +222,10 @@ set_timeout(State0=#state{opts=Opts, streams=Streams}) -> [] -> {request_timeout, 5000}; _ -> {idle_timeout, 60000} end, - Timeout = maps:get(Name, Opts, Default), - TimerRef = erlang:start_timer(Timeout, self(), Name), + TimerRef = case maps:get(Name, Opts, Default) of + infinity -> undefined; + Timeout -> erlang:start_timer(Timeout, self(), Name) + end, State#state{timer=TimerRef}. cancel_timeout(State=#state{timer=TimerRef}) -> |