Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
4062-ssl-Sync-dtls-closing.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4062-ssl-Sync-dtls-closing.patch of Package erlang
From 6f1fd30396626d99faf72668964badc1c1e7dc20 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson <dgud@erlang.org> Date: Wed, 27 Mar 2024 10:09:28 +0100 Subject: [PATCH 2/3] ssl: Sync dtls closing Fixes some wobbling listening tests, that fails with already_listening --- lib/ssl/src/dtls_packet_demux.erl | 4 ++-- lib/ssl/src/dtls_socket.erl | 24 ++++++++++++++++++------ lib/ssl/src/ssl.erl | 7 ++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/ssl/src/dtls_packet_demux.erl b/lib/ssl/src/dtls_packet_demux.erl index 6623d6cc16..a3778fe1c7 100644 --- a/lib/ssl/src/dtls_packet_demux.erl +++ b/lib/ssl/src/dtls_packet_demux.erl @@ -149,9 +149,9 @@ handle_call(sockname, _, #state{listener = Socket} = State) -> handle_call(close, _, State0) -> case do_close(State0) of {stop, State} -> - {stop, normal, ok, State}; + {stop, normal, stop, State}; {wait, State} -> - {reply, ok, State} + {reply, waiting, State} end; handle_call({new_owner, Owner}, _, State) -> {reply, ok, State#state{close = false, first = true, owner = Owner}}; diff --git a/lib/ssl/src/dtls_socket.erl b/lib/ssl/src/dtls_socket.erl index b5302e9b6c..2f8f7ed5d2 100644 --- a/lib/ssl/src/dtls_socket.erl +++ b/lib/ssl/src/dtls_socket.erl @@ -35,7 +35,7 @@ sockname/2, port/2, close/2, - close/1 + close_listen/2 ]). -export([emulated_options/0, @@ -94,17 +94,29 @@ connect(Address, Port, #config{transport_info = {Transport, _, _, _, _} = CbInfo Error end. -close(#sslsocket{pid = {dtls, #config{dtls_handler = {Pid, Port0}, - inet_ssl = SockOpts}}}) -> +close_listen(#sslsocket{pid = {dtls, #config{dtls_handler = {Pid, Port0}, + inet_ssl = SockOpts}}}, Timeout) -> IP = proplists:get_value(ip, SockOpts, default_ip(SockOpts)), Port = get_real_port(Pid, Port0), dtls_listener_sup:register_listener({undefined, Pid}, IP, Port), - dtls_packet_demux:close(Pid). + case dtls_packet_demux:close(Pid) of + stop -> + erlang:monitor(process, Pid), + receive {'DOWN', _, process, Pid, _} -> + ok + after Timeout -> + {error, timeout} + end; + waiting -> + ok; + Error -> + Error + end. default_ip(SockOpts) -> case proplists:get_value(inet6, SockOpts, false) of - false -> {0,0,0,0}; - true -> {0,0,0,0, 0,0,0,0} + false -> {0,0,0,0}; + true -> {0,0,0,0, 0,0,0,0} end. close(gen_udp, {_Client, _Socket}) -> diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl index 93a2c04250..c331de0f36 100644 --- a/lib/ssl/src/ssl.erl +++ b/lib/ssl/src/ssl.erl @@ -2240,7 +2240,7 @@ handshake_cancel(Socket) -> close(#sslsocket{pid = [Pid|_]}) when is_pid(Pid) -> ssl_gen_statem:close(Pid, {close, ?DEFAULT_TIMEOUT}); close(#sslsocket{pid = {dtls, #config{dtls_handler = {_, _}}}} = DTLSListen) -> - dtls_socket:close(DTLSListen); + dtls_socket:close_listen(DTLSListen, ?DEFAULT_TIMEOUT); close(#sslsocket{pid = {ListenSocket, #config{transport_info={Transport,_,_,_,_}}}}) -> Transport:close(ListenSocket). @@ -2276,8 +2276,9 @@ close(#sslsocket{pid = [TLSPid|_]}, close(#sslsocket{pid = [TLSPid|_]}, Timeout) when is_pid(TLSPid), ?IS_TIMEOUT(Timeout) -> ssl_gen_statem:close(TLSPid, {close, Timeout}); -close(#sslsocket{pid = {dtls, #config{dtls_handler = {_, _}}}} = DTLSListen, _) -> - dtls_socket:close(DTLSListen); +close(#sslsocket{pid = {dtls, #config{dtls_handler = {_, _}}}} = DTLSListen, Timeout) + when ?IS_TIMEOUT(Timeout) -> + dtls_socket:close_listen(DTLSListen, Timeout); close(#sslsocket{pid = {ListenSocket, #config{transport_info={Transport,_,_,_,_}}}}, _) -> tls_socket:close(Transport, ListenSocket). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor