64 Commits

Author SHA1 Message Date
Alex Rønne Petersen fa9caeba1b std.Io.net.test: disable listen on a port, send bytes, receive bytes
Still happens: https://codeberg.org/ziglang/zig/issues/31388#issuecomment-12968295
2026-04-11 06:50:53 +02:00
Jacob Young 0db75c0116 std.Io.Threaded: fix dns queries on windows
by working around various bugs in `DnsQueryEx`.

Closes #31659
2026-03-30 09:33:04 +02:00
Evgenii Orlov 0ee6a79da5 std.Io.net.HostName.netLookup: make canonical_name_buffer optional 2026-03-23 11:02:47 +01:00
Jacob Young ccf8e223f4 std.Io.net: disable unix socket test due to presumed windows kernel bug
Tracked by #31499
2026-03-22 09:37:12 -04:00
Jacob Young 9ac1386c10 std.Io.Threaded: windows networking without ws2_32 2026-03-18 20:13:59 -04:00
Guillaume 065c6e7946 std.Io.net.HostName: simplify validate logic (#30764)
Follow-up of efe649b13e

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30764
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Guillaume <guillaume.alabre@gmail.com>
Co-committed-by: Guillaume <guillaume.alabre@gmail.com>
2026-03-15 09:11:11 +01:00
Andrew Kelley a7b686ac5e std: disable flaky test on Windows
tracked by #31499
2026-03-14 06:06:03 +01:00
Andrew Kelley 314264ee7d std: windows isn't passing cancel accept yet
tracked by #30865
2026-03-12 15:42:13 -07:00
Andrew Kelley 1c9bd1d74c std.Io.net: enable all the tests
closes #18315
closes #25983
closes #31388
2026-03-12 15:40:59 -07:00
Alex Rønne Petersen ce32003625 std.Io.net.test: disable listen on a port, send bytes, receive bytes
https://codeberg.org/ziglang/zig/issues/31388
2026-03-04 01:21:08 +01:00
Andrew Kelley 922ab8b8bc std: finish moving time to Io interface
Importantly, adds ability to get Clock resolution, which may be zero.
This allows error.Unexpected and error.ClockUnsupported to be removed
from timeout and clock reading error sets.
2026-02-02 23:02:31 -08:00
Kevin Primm b929078dac std.Io.Threaded: Raise specific error when DNS lookup returns no A/AAAA records
closes #25948
2026-01-08 20:44:47 -08:00
Jon Parise efe649b13e std.Io.net: make HostName.validate RFC 1123-compliant
The implementation of HostName.validate was too generous. It considered
strings like ".example.com", "exa..mple.com", and "-example.com" to be
valid hostnames, which is incorrect according to RFC 1123 (the currently
accepted standard).

Reviewed-on: https://github.com/ziglang/zig/pull/25710
2026-01-08 20:40:32 -08:00
Andrew Kelley 7248b4a4e4 std.fs: deprecate base64 APIs
100% of std.fs is now deprecated.
2026-01-07 17:33:06 -08:00
Andrew Kelley 1f1381a866 update API usage of std.crypto.random to io.random 2026-01-07 11:03:36 -08:00
Matthew Lugg 3bb2f7b84e std.Io.net: don't swallow 'error.Canceled'
This was missed when updating to the new group cancelation API, and
caused illegal behavior in many cases (the condition was simply that a
DNS query returned a second result before a connection was successfully
established).
2026-01-03 15:45:11 +00:00
Andrew Kelley 2adfd4d107 std.Io: fix and improve Group API
Rename `wait` to `await` to be consistent with Future API. The
convention here is that this set of functionality goes together:
* async/concurrent
* await/cancel

Also rename Select `wait` to `await` for the same reason.

`Group.await` now can return `error.Canceled`. Furthermore,
`Group.await` does not auto-propagate cancelation. Instead, users should
follow the pattern of `defer group.cancel(io);` after initialization,
and doing `try group.await(io);` at the end of the success path.
Advanced logic can choose to do something other than this pattern in the
event of cancelation.

Additionally, fixes a bug in `std.Io.Threaded` future await, in which it
swallowed an `error.Canceled`. Now if a task is canceled while awaiting
a future, after propagating the cancel request, it also recancels,
meaning that the awaiting task will properly detect its own cancelation
at the next cancelation point.

Furthermore, fixes a bug in the compiler where `error.Canceled` was
being swallowed in `dispatchPrelinkWork`.

Finally, fixes std.crypto code that inappropriately used
`catch unreachable` in response to cancelation without even so much as a
comment explaining why it was believed to be unreachable. Now, those
functions have `error.Canceled` in the error set and propagate
cancelation properly.

With this way of doing things, `Group.await` has a nice property: even if
all tasks in the group are CPU bound and without cancelation points, the
`Group.await` can still be canceled. In such case, the task that was
waiting for `await` wakes up with a chance to do some more resource
cleanup tasks, such as canceling more things, before entering the
deferred `Group.cancel` call at which point it has to suspend until the
canceled but uninterruptible CPU bound tasks complete.

closes #30601
2025-12-29 22:47:34 -08:00
Lukas Lalinsky e8a2e6578a Add std.Io.net.Stream.shutdown 2025-12-29 02:20:37 +01:00
Andrew Kelley feeed922e1 std.Io.net: disable flaky test on mipsel 2025-12-26 19:58:56 -08:00
Andrew Kelley bee8005fe6 std.heap.DebugAllocator: never detect TTY config
instead, allow the user to set it as a field.

this fixes a bug where leak printing and error printing would run tty
config detection for stderr, and then emit a log, which is not necessary
going to print to stderr.

however, the nice defaults are gone; the user must explicitly assign the
tty_config field during initialization or else the logging will not have
color.

related: https://github.com/ziglang/zig/issues/24510
2025-12-23 22:15:08 -08:00
Andrew Kelley 4a53e5b0b4 fix a handful of compilation errors related to std.fs migration 2025-12-23 22:15:08 -08:00
Andrew Kelley f53248a409 update all std.fs.cwd() to std.Io.Dir.cwd() 2025-12-23 22:15:08 -08:00
Andrew Kelley aafddc2ea1 update all occurrences of close() to close(io) 2025-12-23 22:15:07 -08:00
Matthew Lugg 67eed99550 std.Io.Queue: introduce closure and fix a bug
Queues can now be "closed". A closed queue cannot have more elements
appended with `put`, and blocked calls to `put` will immediately unblock
having failed to append some elements. Calls to `get` will continue to
succeed as long as the queue buffer is non-empty, but will then never
block; already-blocked calls to `get` will unblock.

All queue get/put operations can now return `error.Closed` to indicate
that the queue has been closed. For bulk get/put operations, they may
add/receive fewer elements than the minimum requested *if* the queue was
closed or the calling task was canceled. In that case, if any elements
were already added/received, they are returned first, and successive
calls will return `error.Closed` or `error.Canceled`.

Also, fix a bug where `Queue.get` could deadlock because it incorrectly
blocked until the given buffer was *filled*.

Resolves: #30141
2025-12-21 13:07:04 +00:00
Alex Rønne Petersen 5078acf3a3 std.Io.net: disable listen on a unix socket, send bytes, receive bytes on Windows
https://github.com/ziglang/zig/issues/25983
2025-11-19 21:51:57 +01:00
0x4a61636f62 2e6f7d36b9 std.Io.net: fix off-by-one in HostName.expand
`HostName.expand` was including the null terminator in the slice passed to `HostName.init`, which caused `HostName.validate` to fail.
2025-11-13 21:04:21 -08:00
Andrew Kelley 03fd132b1c std.Io: fix Group.wait unsoundness
Previously if a Group.wait was canceled, then a subsequent call to
wait() or cancel() would trip an assertion in the synchronization code.
2025-10-29 06:20:52 -07:00
Andrew Kelley 441d0c4272 std.Io.net.HostName: fix missing group cancel 2025-10-29 06:20:51 -07:00
Andrew Kelley f9de83c90e std.Io.net: skip testing netInterfaceNameResolve on Windows
let's handle this in a follow-up change. implementation needs to use
ConvertInterfaceNameToLuidW and the additional dependency on
Iphlpapi.dll poses some challenges.
2025-10-29 06:20:51 -07:00
Andrew Kelley d257b1337a std.Io.Threaded: fix compilation failures on Windows 2025-10-29 06:20:50 -07:00
Andrew Kelley 10b1eef2d3 std: fix compilation errors on Windows 2025-10-29 06:20:50 -07:00
Andrew Kelley b215f8667a std.Io.net.HostName.ResolvConf: ignore nameservers above max 2025-10-29 06:20:50 -07:00
Andrew Kelley f14c4c3db8 std.Io.net.HostName: fix connectMany not running DNS async 2025-10-29 06:20:50 -07:00
Andrew Kelley f7bbcb4a4b fix miscellaneous compilation failures 2025-10-29 06:20:50 -07:00
Andrew Kelley 90fdd21df6 std: move DNS record enum to a better namespace 2025-10-29 06:20:50 -07:00
Andrew Kelley 060fd975d9 std.Io.Group: add cancellation support to "wait" 2025-10-29 06:20:49 -07:00
Andrew Kelley 870a682cd8 std.Io.net.HostName.connect: fix resource leaks
Must free other succeeded connections that lost the race.
2025-10-29 06:20:49 -07:00
Andrew Kelley adaef433d2 std.net.HostName.connect: rework to avoid waiting for DNS
The previous implementation would eagerly attempt TCP connection upon
receiving a DNS reply, but it would still wait for all the DNS results
before returning from the function.

This implementation returns immediately upon first successful TCP
connection, canceling not only in-flight TCP connection attempts but
also unfinished DNS queries.
2025-10-29 06:20:49 -07:00
Andrew Kelley d3c4158a10 std.Io: implement Select
and finish implementation of HostName.connect
2025-10-29 06:20:49 -07:00
Andrew Kelley 35ce907c06 std.Io.net.HostName: move lookup to the interface
Unfortunately this can't be implemented "above the vtable" because
various operating systems don't provide low level DNS resolution
primitives such as just putting the list of nameservers in a file.

Without libc on Linux it works great though!

Anyway this also changes the API to be based on Io.Queue. By using a
large enough buffer, reusable code can be written that does not require
concurrent, yet takes advantage of responding to DNS queries as they
come in. I sketched out a new implementation of `HostName.connect` to
demonstrate this, but it will require an additional API (`Io.Select`) to
be implemented in a future commit.

This commit also introduces "uncancelable" variants for mutex locking,
waiting on a condition, and putting items into a queue.
2025-10-29 06:20:49 -07:00
Andrew Kelley e8cea8accb std.Io.Threaded: implement netListenUnix 2025-10-29 06:20:49 -07:00
Andrew Kelley 539808239e std.net: IPv6 parsing fixes 2025-10-29 06:20:49 -07:00
Andrew Kelley d3f0c460ec std.Io.net.HostName: fix DNS resolution
* merge conflict with changing behavior of takeDelimiterExclusive
* check bounds before adding to result array
2025-10-29 06:20:49 -07:00
Andrew Kelley 923a7bdd7e std.Io.net: fix parsing IPv4-mapped IPv6 addresses 2025-10-29 06:20:49 -07:00
Andrew Kelley 3b34622368 std.Io: add unix domain sockets API
note that "reuseaddr" does nothing for these
2025-10-29 06:20:49 -07:00
Andrew Kelley ebcc6f166c std.Io: bring back Timestamp but also keep Clock.Timestamp
this feels better
2025-10-29 06:20:49 -07:00
Andrew Kelley 47aa5a70a5 std: updating to std.Io interface
got the build runner compiling
2025-10-29 06:20:48 -07:00
Andrew Kelley b428612a20 WIP: hack away at std.Io return flight 2025-10-29 06:20:48 -07:00
Andrew Kelley 774df26835 WIP: hack at std.Io on a plane 2025-10-29 06:20:48 -07:00
Andrew Kelley 00f26cb0a4 WIP land the std.Io interface
fix std lib compilation errors caused by introducing std.Io
2025-10-29 06:20:48 -07:00