Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0240-esock-enet-Fixed-net-getaddrinfo.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0240-esock-enet-Fixed-net-getaddrinfo.patch of Package erlang
From eddca2b05e80dc2ee64895c97fd33ab94db45151 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Thu, 11 Jul 2024 13:35:21 +0200 Subject: [PATCH] [esock|enet] Fixed net:getaddrinfo The socket type field of the address info map was incurrectly called 'type' sintead of 'socktype'. This has now been corrected. OTP-19132 --- erts/emulator/nifs/common/prim_net_nif.c | 15 +++++++++++---- erts/emulator/nifs/common/prim_socket_nif.c | 1 + erts/emulator/nifs/common/socket_int.h | 1 + lib/kernel/src/net.erl | 14 +++++++------- lib/kernel/test/net_SUITE.erl | 2 +- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/erts/emulator/nifs/common/prim_net_nif.c b/erts/emulator/nifs/common/prim_net_nif.c index f8dc1856cd..e5b4502e0e 100644 --- a/erts/emulator/nifs/common/prim_net_nif.c +++ b/erts/emulator/nifs/common/prim_net_nif.c @@ -4751,17 +4751,24 @@ ERL_NIF_TERM encode_address_info_family(ErlNifEnv* env, /* Convert an "native" socket type to an erlang socket type. * Note that this is not currently exhaustive, but only supports - * stream and dgram. Other values will be returned as is, that is - * in the form of an integer. + * stream, dgram, raw, seqpacket and rdm. + * Also, the value 0 (zero) has the special meaning: any. + * Other values will be returned as is, that is in the form of + * an integer. */ static ERL_NIF_TERM encode_address_info_type(ErlNifEnv* env, int socktype) { ERL_NIF_TERM etype; + ERL_NIF_TERM zero = MKI(env, 0); esock_encode_type(env, socktype, &etype); - return etype; + + if (IS_IDENTICAL(zero, etype)) + return esock_atom_any; + else + return etype; } @@ -4775,7 +4782,7 @@ void make_address_info(ErlNifEnv* env, ERL_NIF_TERM* ai) { ERL_NIF_TERM keys[] = {esock_atom_family, - esock_atom_type, + esock_atom_socktype, esock_atom_protocol, esock_atom_addr}; ERL_NIF_TERM vals[] = {fam, sockType, proto, addr}; diff --git a/erts/emulator/nifs/common/prim_socket_nif.c b/erts/emulator/nifs/common/prim_socket_nif.c index c147c07b22..80d7072c9a 100644 --- a/erts/emulator/nifs/common/prim_socket_nif.c +++ b/erts/emulator/nifs/common/prim_socket_nif.c @@ -2260,6 +2260,7 @@ static const struct in6_addr in6addr_loopback = GLOBAL_ATOM_DECL(snd_wnd); \ GLOBAL_ATOM_DECL(sockaddr); \ GLOBAL_ATOM_DECL(socket); \ + GLOBAL_ATOM_DECL(socktype); \ GLOBAL_ATOM_DECL(spec_dst); \ GLOBAL_ATOM_DECL(staticarp); \ GLOBAL_ATOM_DECL(state); \ diff --git a/erts/emulator/nifs/common/socket_int.h b/erts/emulator/nifs/common/socket_int.h index 82fbd85331..c88efdd02d 100644 --- a/erts/emulator/nifs/common/socket_int.h +++ b/erts/emulator/nifs/common/socket_int.h @@ -535,6 +535,7 @@ typedef long ssize_t; GLOBAL_ATOM_DEF(sockaddr); \ GLOBAL_ATOM_DEF(socket); \ GLOBAL_ATOM_DEF(socket_tag); \ + GLOBAL_ATOM_DEF(socktype); \ GLOBAL_ATOM_DEF(spec_dst); \ GLOBAL_ATOM_DEF(state); \ GLOBAL_ATOM_DEF(status); \ diff --git a/lib/kernel/src/net.erl b/lib/kernel/src/net.erl index 2f3fe5c83d..1513516bac 100644 --- a/lib/kernel/src/net.erl +++ b/lib/kernel/src/net.erl @@ -174,13 +174,13 @@ net:getifaddrs( %% The following (ext) flags has been removed %% (as they are deprecated by later version of gcc): %% idn_allow_unassigned | idn_use_std3_ascii_rules. --type name_info_flag_ext() :: idn. --type name_info() :: #{host := string(), - service := string()}. --type address_info() :: #{family := socket:domain(), - socktype := socket:type(), - protocol := socket:protocol(), - address := socket:sockaddr()}. +-type name_info_flag_ext() :: idn. +-type name_info() :: #{host := string(), + service := string()}. +-type address_info() :: #{family := socket:domain(), + socktype := any | socket:type() | integer(), + protocol := socket:protocol(), + address := socket:sockaddr()}. -type network_interface_name() :: string(). -type network_interface_index() :: non_neg_integer(). diff --git a/lib/kernel/test/net_SUITE.erl b/lib/kernel/test/net_SUITE.erl index 62bdbef7f4..a19666dd1a 100644 --- a/lib/kernel/test/net_SUITE.erl +++ b/lib/kernel/test/net_SUITE.erl @@ -763,7 +763,7 @@ verify_addr_info2([#{addr := #{addr := Addr, family := Domain, port := Port}, family := Domain, - type := _Type, + socktype := _Type, protocol := _Proto}|T], Domain) when is_integer(Port) andalso (((Domain =:= inet) andalso is_tuple(Addr) andalso (size(Addr) =:= 4)) orelse -- 2.43.0
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