diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/gun.erl | 14 |
2 files changed, 6 insertions, 10 deletions
@@ -7,7 +7,7 @@ PROJECT_VERSION = 1.0.0-pre.2 # Options. PLT_APPS = ssl -CT_OPTS += -pa test -ct_hooks gun_ct_hook [] -boot start_sasl +CT_OPTS += -pa test -ct_hooks gun_ct_hook [] # -boot start_sasl CI_OTP ?= OTP-18.0.3 OTP-18.1.5 OTP-18.2.4.1 OTP-18.3.4.4 OTP-19.0.7 OTP-19.1.6 #CI_HIPE ?= $(lastword $(CI_OTP)) diff --git a/src/gun.erl b/src/gun.erl index 3edc698..44d818e 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -506,7 +506,7 @@ connect(State=#state{host=Host, port=Port, opts=Opts, transport=Transport=ranch_ end, up(State, Socket, Protocol, ProtoOptsKey); {error, _} -> - retry(State, Retries - 1) + retry(State, Retries) end; connect(State=#state{host=Host, port=Port, opts=Opts, transport=Transport}, Retries) -> TransportOpts = [binary, {active, false} @@ -520,7 +520,7 @@ connect(State=#state{host=Host, port=Port, opts=Opts, transport=Transport}, Retr end, up(State, Socket, Protocol, ProtoOptsKey); {error, _} -> - retry(State, Retries - 1) + retry(State, Retries) end. up(State=#state{owner=Owner, opts=Opts, transport=Transport}, Socket, Protocol, ProtoOptsKey) -> @@ -535,9 +535,8 @@ down(State=#state{owner=Owner, opts=Opts, protocol=Protocol, protocol_state=Prot retry(State#state{socket=undefined, protocol=undefined, protocol_state=undefined}, maps:get(retry, Opts, 5)). -%% Exit normally if the retry functionality has been disabled. retry(_, 0) -> - ok; + error(gone); retry(State=#state{keepalive_ref=KeepaliveRef}, Retries) when is_reference(KeepaliveRef) -> _ = erlang:cancel_timer(KeepaliveRef), %% Flush if we have a keepalive message @@ -546,13 +545,10 @@ retry(State=#state{keepalive_ref=KeepaliveRef}, Retries) when is_reference(Keepa after 0 -> ok end, - retry_loop(State#state{keepalive_ref=undefined}, Retries); + retry_loop(State#state{keepalive_ref=undefined}, Retries - 1); retry(State, Retries) -> - retry_loop(State, Retries). + retry_loop(State, Retries - 1). -%% Too many retries, give up. -retry_loop(_, 0) -> - error(gone); retry_loop(State=#state{parent=Parent, opts=Opts}, Retries) -> _ = erlang:send_after(maps:get(retry_timeout, Opts, 5000), self(), retry), receive |