@@ -104,6 +104,18 @@ hs_data_inet_tcp(Driver, Socket) ->
104104 end }.
105105
106106hs_data_ssl (Family , # sslsocket {payload_sender = DistCtrl } = SslSocket ) ->
107+ % % The distribution controller (output controller) needs to be linked
108+ % % to the caller, which becomes the distribution ticker
109+ % % after distribution handshake.
110+ % %
111+ % % net_kernel takes down either the distribution controller
112+ % % or the ticker, but all processes involved in the channel
113+ % % must be taken down when the channel goes down.
114+ % %
115+ % % The SSL socket receiver and payload sender will go down
116+ % % together thanks to their supervisor.
117+ % %
118+ link (DistCtrl ),
107119 {ok , Address } =
108120 maybe
109121 {error , einval } ?= ssl :peername (SslSocket ),
@@ -513,15 +525,13 @@ do_accept(
513525 Timer = dist_util :start_timer (SetupTime ),
514526 {HSData0 , NewAllowed } =
515527 case DistSocket of
516- SslSocket = # sslsocket {payload_sender = Sender } ->
517- link (Sender ),
518- {hs_data_ssl (Family , SslSocket ),
519- allowed_nodes (SslSocket , Allowed )};
528+ SslSocket = # sslsocket {} ->
529+ HSDataSsl = hs_data_ssl (Family , SslSocket ),
530+ {HSDataSsl , allowed_nodes (SslSocket , Allowed )};
520531 PortSocket when is_port (DistSocket ) ->
521532 % %% XXX Breaking abstraction barrier
522533 Driver = erlang :port_get_data (PortSocket ),
523- {hs_data_inet_tcp (Driver , PortSocket ),
524- Allowed }
534+ {hs_data_inet_tcp (Driver , PortSocket ), Allowed }
525535 end ,
526536 HSData =
527537 HSData0 # hs_data {
@@ -648,13 +658,14 @@ do_setup(
648658 KTLS = proplists :get_value (ktls , Opts , false ),
649659 dist_util :reset_timer (Timer ),
650660 maybe
651- {ok , # sslsocket { connection_handler = Receiver , payload_sender = Sender } = SslSocket } ?=
661+ {ok , SslSocket } ?=
652662 ssl :connect (IP , PortNum , Opts , net_kernel :connecttime ()),
653663 HSData =
654664 case KTLS of
655665 true ->
656666 {ok , KtlsInfo } =
657- ssl_gen_statem :ktls_handover (Receiver ),
667+ ssl_gen_statem :ktls_handover (
668+ SslSocket # sslsocket .connection_handler ),
658669 Socket = maps :get (socket , KtlsInfo ),
659670 case inet_set_ktls (KtlsInfo ) of
660671 ok when is_port (Socket ) ->
@@ -667,9 +678,7 @@ do_setup(
667678 trace ({set_ktls_failed , KtlsReason }))
668679 end ;
669680 false ->
670- _ = monitor_pid (Sender ),
671681 ok = ssl :controlling_process (SslSocket , self ()),
672- link (Sender ),
673682 hs_data_ssl (Family , SslSocket )
674683 end
675684 # hs_data {
0 commit comments