From 0fe54af72b81fdb198a377198d7f3a91f9ad6d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 14 Aug 2017 14:57:59 +0200 Subject: Allow an infinity keepalive value This disables the keepalive mechanism entirely. --- src/gun.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gun.erl') diff --git a/src/gun.erl b/src/gun.erl index 4857344..e9155b2 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -624,7 +624,10 @@ before_loop(State=#state{opts=Opts, protocol=Protocol}) -> end, ProtoOpts = maps:get(ProtoOptsKey, Opts, #{}), Keepalive = maps:get(keepalive, ProtoOpts, 5000), - KeepaliveRef = erlang:send_after(Keepalive, self(), keepalive), + KeepaliveRef = case Keepalive of + infinity -> undefined; + _ -> erlang:send_after(Keepalive, self(), keepalive) + end, loop(State#state{keepalive_ref=KeepaliveRef}). loop(State=#state{parent=Parent, owner=Owner, owner_ref=OwnerRef, host=Host, port=Port, opts=Opts, -- cgit v1.2.3