| author | |
| committer | |
| log | c75ae8b66d57d9e7c195121e1d8d8ff5ca98e73d |
| tree | 6edc6ae92d6471fd26c625af568a87078fb81f54 |
| parent | 785a6c1aa9a7979a962db9d741a53897c423cb92 |
On OpenBSD, connecting to a newly-allocated port on an unspecified IPv4
host address causes EINVAL. This was found by @mikdusan when running TCP
tests on OpenBSD.
This commit fixes TCP tests on OpenBSD by having all tests that allocate
a new host-port pair to have the host IPv4/IPv6 address point to the
host's loopback adapter (on localhost).3 files changed, 13 insertions(+), 2 deletions(-)
lib/std/x/net/ip.zig+2| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | |
| 7 | 7 | const std = @import("../../std.zig"); |
| 8 | 8 | |
| 9 | const fmt = std.fmt; | |
| 10 | ||
| 9 | 11 | const IPv4 = std.x.os.IPv4; |
| 10 | 12 | const IPv6 = std.x.os.IPv6; |
| 11 | 13 | const Socket = std.x.os.Socket; |
lib/std/x/net/tcp.zig+10-2| ... | ... | @@ -282,7 +282,11 @@ test "tcp: create client/listener pair" { |
| 282 | 282 | try listener.bind(ip.Address.initIPv4(IPv4.unspecified, 0)); |
| 283 | 283 | try listener.listen(128); |
| 284 | 284 | |
| 285 | const binded_address = try listener.getLocalAddress(); | |
| 285 | var binded_address = try listener.getLocalAddress(); | |
| 286 | switch (binded_address) { | |
| 287 | .ipv4 => |*ipv4| ipv4.host = IPv4.localhost, | |
| 288 | .ipv6 => |*ipv6| ipv6.host = IPv6.localhost, | |
| 289 | } | |
| 286 | 290 | |
| 287 | 291 | const client = try tcp.Client.init(.ip, os.SOCK_CLOEXEC); |
| 288 | 292 | defer client.deinit(); |
| ... | ... | @@ -302,7 +306,11 @@ test "tcp/client: set read timeout of 1 millisecond on blocking client" { |
| 302 | 306 | try listener.bind(ip.Address.initIPv4(IPv4.unspecified, 0)); |
| 303 | 307 | try listener.listen(128); |
| 304 | 308 | |
| 305 | const binded_address = try listener.getLocalAddress(); | |
| 309 | var binded_address = try listener.getLocalAddress(); | |
| 310 | switch (binded_address) { | |
| 311 | .ipv4 => |*ipv4| ipv4.host = IPv4.localhost, | |
| 312 | .ipv6 => |*ipv6| ipv6.host = IPv6.localhost, | |
| 313 | } | |
| 306 | 314 | |
| 307 | 315 | const client = try tcp.Client.init(.ip, os.SOCK_CLOEXEC); |
| 308 | 316 | defer client.deinit(); |
lib/std/x/os/Socket.zig+1| ... | ... | @@ -8,6 +8,7 @@ const std = @import("../../std.zig"); |
| 8 | 8 | const net = @import("net.zig"); |
| 9 | 9 | |
| 10 | 10 | const os = std.os; |
| 11 | const fmt = std.fmt; | |
| 11 | 12 | const mem = std.mem; |
| 12 | 13 | const time = std.time; |
| 13 | 14 |