authorgravatar for ansg191@anshulg.comAnshul Gupta <ansg191@anshulg.com> 2026-06-01 16:48:12-07:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-09 15:49:05+02:00
logcb7c6e391872d2922a688c77def805883b69eba8
tree4d61dd352022fb612156d5771060fa5c25a15b2f
parentb2c230df5033864a19eb65defceac1cc3013be3c

std.Io.Threaded: respect options.family in netLookup

Previously `AF_UNSPEC` was passed unconditionally to `getaddrinfo`. This specifies `AF_INET` or `AF_INET6` depending on the value of HostName.LookupOptions.family. `AF_UNSPEC` is still set by default (when family == null).

1 files changed, 6 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+6-1
...@@ -13923,9 +13923,14 @@ fn netLookupFallible(...@@ -13923,9 +13923,14 @@ fn netLookupFallible(
13923 var port_buffer: [8]u8 = undefined;13923 var port_buffer: [8]u8 = undefined;
13924 const port_c = std.fmt.bufPrintSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable;13924 const port_c = std.fmt.bufPrintSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable;
1392513925
13926 const family: i32 = if (options.family) |f| switch (f) {
13927 .ip4 => posix.AF.INET,
13928 .ip6 => posix.AF.INET6,
13929 } else posix.AF.UNSPEC;
13930
13926 const hints: posix.addrinfo = .{13931 const hints: posix.addrinfo = .{
13927 .flags = .{ .CANONNAME = options.canonical_name_buffer != null, .NUMERICSERV = true },13932 .flags = .{ .CANONNAME = options.canonical_name_buffer != null, .NUMERICSERV = true },
13928 .family = posix.AF.UNSPEC,13933 .family = family,
13929 .socktype = posix.SOCK.STREAM,13934 .socktype = posix.SOCK.STREAM,
13930 .protocol = posix.IPPROTO.TCP,13935 .protocol = posix.IPPROTO.TCP,
13931 .canonname = null,13936 .canonname = null,