From 18a59bf3b0c12432783eccb3e847999f9fbee6cf Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Thu, 27 May 2010 09:01:10 +0000 Subject: 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. --- lib/ssl/src/ssl_connection.erl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/ssl') 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. -- cgit v1.2.3