aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2010-05-27 09:01:10 +0000
committerErlang/OTP <[email protected]>2010-05-27 09:01:10 +0000
commit18a59bf3b0c12432783eccb3e847999f9fbee6cf (patch)
treebd3337177ce822c7b7b452c81e9e6f8c348c38ee
parent8d498e5eb9687fbbe6df9b49540f40e201f0d37a (diff)
downloadotp-18a59bf3b0c12432783eccb3e847999f9fbee6cf.tar.gz
otp-18a59bf3b0c12432783eccb3e847999f9fbee6cf.tar.bz2
otp-18a59bf3b0c12432783eccb3e847999f9fbee6cf.zip
Moved nodelay workaround for linux, as it seems to only work if you do
it before sending the fatal alert, even though documentation suggests the socket will be flushed on linux as an effect of setting the nodelay option.
-rw-r--r--lib/ssl/src/ssl_connection.erl14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 21c3921e22..2e853c7cc8 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -2049,6 +2049,7 @@ handle_own_alert(Alert, Version, Info,
try %% Try to tell the other side
{BinMsg, _} =
encode_alert(Alert, Version, ConnectionStates),
+ linux_workaround_transport_delivery_problems(Alert, Socket),
Transport:send(Socket, BinMsg)
catch _:_ -> %% Can crash if we are in a uninitialized state
ignore
@@ -2122,12 +2123,19 @@ notify_renegotiater(_) ->
ok.
workaround_transport_delivery_problems(Socket, Transport) ->
- %% Should have the side effect that the socket is flushed on some
- %% platforms e.i. linux, should be harmless otherwise.
- inet:setopts(Socket, [{nodelay, true}]),
%% Standard trick to try to make sure all
%% data sent to to tcp port is really sent
%% before tcp port is closed.
inet:setopts(Socket, [{active, false}]),
Transport:shutdown(Socket, write),
Transport:recv(Socket, 0).
+
+linux_workaround_transport_delivery_problems(#alert{level = ?FATAL}, Socket) ->
+ case os:type() of
+ {unix, linux} ->
+ inet:setopts(Socket, [{nodelay, true}]);
+ _ ->
+ ok
+ end;
+linux_workaround_transport_delivery_problems(_, _) ->
+ ok.