@@ -284,7 +284,7 @@ connection({call, From}, {application_data, Data}, StateData) ->
284284connection ({call , From }, {post_handshake_data , HSData }, # data {buff = Buff } = StateData ) ->
285285 case Buff of
286286 undefined ->
287- send_post_handshake_data (HSData , From , connection , StateData );
287+ send_post_handshake_data (HSData , From , connection , StateData , [{ reply , From , ok }] );
288288 Async ->
289289 {next_state , async_wait , StateData # data {buff = Async # async {low = 0 }}, [postpone ]}
290290 end ;
@@ -328,7 +328,7 @@ connection(internal, {application_packets, From, Data}, StateData) ->
328328connection (internal , {post_handshake_data , From , HSData }, # data {buff = Buff } = StateData ) ->
329329 case Buff of
330330 undefined ->
331- send_post_handshake_data (HSData , From , connection , StateData );
331+ send_post_handshake_data (HSData , From , connection , StateData , [] );
332332 Async ->
333333 {next_state , async_wait , StateData # data {buff = Async # async {low = 0 }}, [postpone ]}
334334 end ;
@@ -554,13 +554,13 @@ send_application_data(Data, From, StateName,
554554 KeyUpdate = tls_handshake_1_3 :key_update (update_requested ),
555555 case DataSz > KeyUpdateAt of
556556 false ->
557- {keep_state_and_data , [{next_event , internal , {post_handshake_data , From , KeyUpdate }},
557+ {keep_state_and_data , [{next_event , internal , {post_handshake_data , undefined , KeyUpdate }},
558558 {next_event , internal , {application_packets , From , Data }}]};
559559 true ->
560560 % % Prevent infinite loop of key updates
561561 {Chunk , Rest } = split_binary (iolist_to_binary (Data ), KeyUpdateAt ),
562- {keep_state_and_data , [{next_event , internal , {post_handshake_data , From , KeyUpdate }},
563- {next_event , internal , {application_packets , From , [Chunk ]}},
562+ {keep_state_and_data , [{next_event , internal , {post_handshake_data , undefined , KeyUpdate }},
563+ {next_event , internal , {application_packets , undefined , [Chunk ]}},
564564 {next_event , internal , {application_packets , From , [Rest ]}}]}
565565 end ;
566566 {renegotiate , _ } ->
@@ -730,7 +730,7 @@ send_post_handshake_data(Handshake, From, StateName,
730730 # data {env = # env {socket = Socket ,
731731 negotiated_version = Version ,
732732 transport_cb = Transport },
733- connection_states = ConnStates0 } = StateData0 ) ->
733+ connection_states = ConnStates0 } = StateData0 , AckAction ) ->
734734 BinHandshake = tls_handshake :encode_handshake (Handshake , Version ),
735735 {Encoded , ConnStates } =
736736 tls_record :encode_handshake (BinHandshake , Version , ConnStates0 ),
@@ -745,7 +745,9 @@ send_post_handshake_data(Handshake, From, StateName,
745745 ok ->
746746 ssl_logger :debug (LogLevel , outbound , 'record' , Encoded ),
747747 StateData = maybe_update_cipher_key (StateData1 , Handshake ),
748- {next_state , StateName , StateData , [{reply , From , ok }]};
748+ % % AckAction will send sync message if post_handshake_data
749+ % % was initiated by peer via the receiver process.
750+ {next_state , StateName , StateData , AckAction };
749751 {error , Reason } ->
750752 death_row_shutdown (Reason , StateData1 )
751753 end .
0 commit comments