[erlang-questions] Non-handled tls packets in the message queue

Park, Sungjin jinni.park@REDACTED
Wed Nov 22 10:09:21 CET 2017


I encountered a problem in receiving tls packets in my application.

After some investigation, I figured out that the process has a tls packet
in it's message queue but didn't have a chance to handle it.  This happens
in a specific situation when the server closes the connection after sending
large data which is split into several packets so that some of them remain
in the message queue when the socket closes by FIN.

I followed OTP code and applied a patch below and confirmed it solved the
problem.  But I'm not quite sure if this is the right way to solve the
problem nor why it was written that way in the first place --
dtls_connection seems to be working just as my patch.

--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -602,12 +602,8 @@ next_record(#state{protocol_buffers =
 next_record(#state{protocol_buffers = #protocol_buffers{tls_packets = [],
tls_cipher_texts = []},
                   socket = Socket,
                   transport_cb = Transport} = State) ->
-    case tls_socket:setopts(Transport, Socket, [{active,once}]) of
-       ok ->
-           {no_record, State};
-       _ ->
-           {socket_closed, State}
-    end;
+    tls_socket:setopts(Transport, Socket, [{active,once}]),
+    {no_record, State};
 next_record(State) ->
     {no_record, State}.

-- 
Park, Sungjin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171122/89b0da00/attachment.htm>


More information about the erlang-questions mailing list