Skip to content

Commit

Permalink
Merge pull request #120 from rabbitmq/replica-listener-backoff
Browse files Browse the repository at this point in the history
Add small backoff when doing replica port scans.
  • Loading branch information
michaelklishin committed May 3, 2023
2 parents 3b0b30b + 6fe567e commit 2d716c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/osiris_replica.erl
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ open_listener(Transport, {Min, Max} = Range, Attempts) ->
{ok, LSock} ->
{Port, LSock};
{error, eaddrinuse} ->
timer:sleep(Attempts),
open_listener(Transport, Range, Attempts + 1);
E ->
throw({stop, E})
Expand Down Expand Up @@ -723,8 +724,12 @@ listener_opts() ->
RcvBuf = application:get_env(osiris, replica_recbuf, ?DEF_REC_BUF),
Buffer = application:get_env(osiris, replica_buffer, RcvBuf * 2),
KeepAlive = application:get_env(osiris, replica_keepalive, false),
ReuseAddr = application:get_env(osiris, replica_reuseaddr, true),
Linger = application:get_env(osiris, replica_linger, true),
LingerTimeout = application:get_env(osiris, replica_linger_timeout, 0),
[binary,
{reuseaddr, true},
{reuseaddr, ReuseAddr},
{linger, {Linger, LingerTimeout}},
{backlog, 0},
{packet, raw},
{active, false},
Expand Down

0 comments on commit 2d716c2

Please sign in to comment.