File 6552-Remove-is_port-guard.patch of Package erlang
From 418b80e5afa6fa0293217aa3cd36dde701550069 Mon Sep 17 00:00:00 2001
From: Anders Svensson <anders@erlang.org>
Date: Tue, 30 Jun 2020 17:37:44 +0200
Subject: [PATCH 2/7] Remove is_port guard
Sockets in gen_tcp have always been ports, but assuming this is abusing
the interface since the type is documented as opaque. The assumption no
longer holds with the socket backend (eg. -kernel inet_backend socket),
so remove the is_port guard in the test functions
diameter_tcp:ports/0,1.
---
lib/diameter/src/transport/diameter_tcp.erl | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/diameter/src/transport/diameter_tcp.erl b/lib/diameter/src/transport/diameter_tcp.erl
index 2c5dc2fa2e..ce4caea72b 100644
--- a/lib/diameter/src/transport/diameter_tcp.erl
+++ b/lib/diameter/src/transport/diameter_tcp.erl
@@ -43,6 +43,7 @@
-export([listener/1,%% diameter_sync callback
info/1]). %% service_info callback
+%% test
-export([ports/0,
ports/1]).
@@ -450,16 +451,20 @@ sock(_, Sock) ->
resolve(Type, S) ->
Sock = sock(Type, S),
try
- ok(portnr(Sock))
+ {ok, T} = portnr(Sock),
+ T
catch
_:_ -> Sock
end.
-portnr(Sock)
- when is_port(Sock) ->
- portnr(gen_tcp, Sock);
+%% Assume either ssl or gen_tcp. In particular, this can't deal with a
+%% transport module that called start/3 with an own module option.
portnr(Sock) ->
- portnr(ssl, Sock).
+ try
+ {ok, _} = portnr(ssl, Sock)
+ catch
+ _:_ -> portnr(gen_tcp, Sock)
+ end.
%% ---------------------------------------------------------------------------
%% # handle_call/3
--
2.34.1