diff options
author | Raimo Niskanen <raimo@erlang.org> | 2020-09-14 11:50:48 +0200 |
---|---|---|
committer | Raimo Niskanen <raimo@erlang.org> | 2020-09-14 11:50:48 +0200 |
commit | 22707e56625b0c0f01eddc42a2f24a335cefb4d6 (patch) | |
tree | 2b5fab87669d1761cea9306ea9c6b9ad1aa26afe | |
parent | 6a2d3a28dcc0a718c9736722a973edb91235b7ba (diff) | |
parent | d824c064dc89079d47be12d650705bb59df981dc (diff) | |
download | erlang-22707e56625b0c0f01eddc42a2f24a335cefb4d6.tar.gz |
Merge branch 'max-au/tls-sender-fix' of https://github.com/max-au/otp into maint
OTP-16851
* tls_sender: avoid livelock timeout for distribution data
-rw-r--r-- | lib/ssl/src/tls_sender.erl | 15 | ||||
-rw-r--r-- | lib/ssl/test/inet_crypto_dist.erl | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/ssl/src/tls_sender.erl b/lib/ssl/src/tls_sender.erl index 7575d0ee8d..51cf0e6073 100644 --- a/lib/ssl/src/tls_sender.erl +++ b/lib/ssl/src/tls_sender.erl @@ -619,7 +619,15 @@ call(FsmPid, Event) -> %%-------------- Erlang distribution helpers ------------------------------ +%% To avoid livelock, dist_data/2 will check for more bytes coming from +%% distribution channel, if amount of already collected bytes greater +%% or equal than the limit defined below. +-define(TLS_BUNDLE_SOFT_LIMIT, 16 * 1024 * 1024). + dist_data(DHandle) -> + dist_data(DHandle, 0). + +dist_data(DHandle, CurBytes) -> case erlang:dist_ctrl_get_data(DHandle) of none -> erlang:dist_ctrl_get_data_notification(DHandle), @@ -628,11 +636,14 @@ dist_data(DHandle) -> %% since the emulator will always deliver a Data %% smaller than 4 GB, and the distribution will %% therefore always have to use {packet,4} - {Len, Data} -> + {Len, Data} when Len + CurBytes >= ?TLS_BUNDLE_SOFT_LIMIT -> %% Data is of type iovec(); lets keep it %% as an iovec()... + erlang:dist_ctrl_get_data_notification(DHandle), + [<<Len:32>> | Data]; + {Len, Data} -> Packet = [<<Len:32>> | Data], - case dist_data(DHandle) of + case dist_data(DHandle, CurBytes + Len) of [] -> Packet; More -> Packet ++ More end diff --git a/lib/ssl/test/inet_crypto_dist.erl b/lib/ssl/test/inet_crypto_dist.erl index 608ebcbe89..b8a2443ba2 100644 --- a/lib/ssl/test/inet_crypto_dist.erl +++ b/lib/ssl/test/inet_crypto_dist.erl @@ -328,7 +328,8 @@ listen(Name) -> gen_listen(Name, ?DRIVER). gen_listen(Name, Driver) -> - case inet_tcp_dist:gen_listen(Driver, Name) of + {ok, Host} = inet:gethostname(), + case inet_tcp_dist:gen_listen(Driver, Name, Host) of {ok, {Socket, Address, Creation}} -> inet:setopts(Socket, socket_options()), {ok, |