diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-10-16 23:40:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-10-29 06:20:50 -0700 |
| commit | cf6fa219fd05b9f2c01e85557bcd140e72802459 (patch) | |
| tree | 7384deba8832c91ae257180835cc3c957912927f /lib/std/Io/net.zig | |
| parent | d4215ffaa04b976400bd597cca0cca8182068bf6 (diff) | |
| download | zig-cf6fa219fd05b9f2c01e85557bcd140e72802459.tar.gz zig-cf6fa219fd05b9f2c01e85557bcd140e72802459.zip | |
std.Io.Threaded: fix netWrite cancellation
Move std.posix logic over rather than calling into it.
Diffstat (limited to 'lib/std/Io/net.zig')
| -rw-r--r-- | lib/std/Io/net.zig | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/std/Io/net.zig b/lib/std/Io/net.zig index 1f47d7e1f5..ca18325e2a 100644 --- a/lib/std/Io/net.zig +++ b/lib/std/Io/net.zig @@ -309,6 +309,7 @@ pub const IpAddress = union(enum) { AccessDenied, /// Non-blocking was requested and the operation cannot return immediately. WouldBlock, + NetworkDown, } || Io.Timeout.Error || Io.UnexpectedError || Io.Cancelable; pub const ConnectOptions = struct { @@ -1062,7 +1063,7 @@ pub const Socket = struct { AddressFamilyUnsupported, /// Another TCP Fast Open is already in progress. FastOpenAlreadyInProgress, - /// Network connection was unexpectedly closed by recipient. + /// Network session was unexpectedly closed by recipient. ConnectionResetByPeer, /// Local end has been shut down on a connection-oriented socket, or /// the socket was never connected. @@ -1242,15 +1243,33 @@ pub const Stream = struct { stream: Stream, err: ?Error = null, - pub const Error = std.posix.SendMsgError || error{ + pub const Error = error{ + /// Another TCP Fast Open is already in progress. + FastOpenAlreadyInProgress, + /// Network session was unexpectedly closed by recipient. ConnectionResetByPeer, - SocketNotBound, - MessageOversize, - NetworkDown, + /// The output queue for a network interface was full. This generally indicates that the + /// interface has stopped sending, but may be caused by transient congestion. (Normally, + /// this does not occur in Linux. Packets are just silently dropped when a device queue + /// overflows.) + /// + /// This is also caused when there is not enough kernel memory available. SystemResources, + /// No route to network. + NetworkUnreachable, + /// Network reached but no route to host. + HostUnreachable, + /// The local network interface used to reach the destination is down. + NetworkDown, + /// The destination address is not listening. + ConnectionRefused, + /// The passed address didn't have the correct address family in its sa_family field. + AddressFamilyUnsupported, + /// Local end has been shut down on a connection-oriented socket, or + /// the socket was never connected. SocketUnconnected, - Unexpected, - } || Io.Cancelable; + SocketNotBound, + } || Io.UnexpectedError || Io.Cancelable; pub fn init(stream: Stream, io: Io, buffer: []u8) Writer { return .{ |
