@@ -282,7 +282,7 @@ connection({call, From}, {application_data, Data}, StateData) ->
282282connection ({call , From }, {post_handshake_data , HSData }, # data {buff = Buff } = StateData ) ->
283283 case Buff of
284284 undefined ->
285- send_post_handshake_data (HSData , From , connection , StateData );
285+ send_post_handshake_data (HSData , From , connection , StateData , [{ reply , From , ok }] );
286286 Async ->
287287 {next_state , async_wait , StateData # data {buff = Async # async {low = 0 }}, [postpone ]}
288288 end ;
@@ -326,7 +326,7 @@ connection(internal, {application_packets, From, Data}, StateData) ->
326326connection (internal , {post_handshake_data , From , HSData }, # data {buff = Buff } = StateData ) ->
327327 case Buff of
328328 undefined ->
329- send_post_handshake_data (HSData , From , connection , StateData );
329+ send_post_handshake_data (HSData , From , connection , StateData , [] );
330330 Async ->
331331 {next_state , async_wait , StateData # data {buff = Async # async {low = 0 }}, [postpone ]}
332332 end ;
@@ -546,13 +546,13 @@ send_application_data(Data, From, StateName,
546546 KeyUpdate = tls_handshake_1_3 :key_update (update_requested ),
547547 case DataSz > KeyUpdateAt of
548548 false ->
549- {keep_state_and_data , [{next_event , internal , {post_handshake_data , From , KeyUpdate }},
549+ {keep_state_and_data , [{next_event , internal , {post_handshake_data , undefined , KeyUpdate }},
550550 {next_event , internal , {application_packets , From , Data }}]};
551551 true ->
552552 % % Prevent infinite loop of key updates
553553 {Chunk , Rest } = split_binary (iolist_to_binary (Data ), KeyUpdateAt ),
554- {keep_state_and_data , [{next_event , internal , {post_handshake_data , From , KeyUpdate }},
555- {next_event , internal , {application_packets , From , [Chunk ]}},
554+ {keep_state_and_data , [{next_event , internal , {post_handshake_data , undefined , KeyUpdate }},
555+ {next_event , internal , {application_packets , undefined , [Chunk ]}},
556556 {next_event , internal , {application_packets , From , [Rest ]}}]}
557557 end ;
558558 {renegotiate , _ } ->
@@ -722,7 +722,7 @@ send_post_handshake_data(Handshake, From, StateName,
722722 # data {env = # env {socket = Socket ,
723723 negotiated_version = Version ,
724724 transport_cb = Transport },
725- connection_states = ConnStates0 } = StateData0 ) ->
725+ connection_states = ConnStates0 } = StateData0 , AckAction ) ->
726726 BinHandshake = tls_handshake :encode_handshake (Handshake , Version ),
727727 {Encoded , ConnStates } =
728728 tls_record :encode_handshake (BinHandshake , Version , ConnStates0 ),
@@ -737,7 +737,9 @@ send_post_handshake_data(Handshake, From, StateName,
737737 ok ->
738738 ssl_logger :debug (LogLevel , outbound , 'record' , Encoded ),
739739 StateData = maybe_update_cipher_key (StateData1 , Handshake ),
740- {next_state , StateName , StateData , [{reply , From , ok }]};
740+ % % AckAction will send sync message if post_handshake_data
741+ % % was initiated by peer via the receiver process.
742+ {next_state , StateName , StateData , AckAction };
741743 {error , Reason } ->
742744 death_row_shutdown (Reason , StateData1 )
743745 end .
0 commit comments