authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-24 04:16:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-24 04:16:53-07:00
log9812bc7b10d093f2041471b166e67748665c89c7
tree45571b20b3482ab0d06545a2a75549068e5b1d45
parentf9bf4d1d60e148683bfdc9b532de97c6cad5bf22

std: map NETNAME_DELETED to error.ConnectionResetByPeer

This was observed in writing to a network stream that was closed on the read end.

3 files changed, 8 insertions(+), 8 deletions(-)

lib/std/os.zig-3
......@@ -836,9 +836,6 @@ pub const ReadError = error{
836836 NotOpenForReading,
837837 SocketNotConnected,
838838
839 // Windows only
840 NetNameDeleted,
841
842839 /// This error occurs when no global event loop is configured,
843840 /// and reading from the file descriptor would block.
844841 WouldBlock,
lib/std/os/windows.zig+8-4
......@@ -453,7 +453,8 @@ pub fn FindClose(hFindFile: HANDLE) void {
453453
454454pub const ReadFileError = error{
455455 BrokenPipe,
456 NetNameDeleted,
456 /// The specified network name is no longer available.
457 ConnectionResetByPeer,
457458 OperationAborted,
458459 Unexpected,
459460};
......@@ -485,7 +486,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64) ReadFileError!usiz
485486 .OPERATION_ABORTED => continue,
486487 .BROKEN_PIPE => return 0,
487488 .HANDLE_EOF => return 0,
488 .NETNAME_DELETED => return error.NetNameDeleted,
489 .NETNAME_DELETED => return error.ConnectionResetByPeer,
489490 else => |err| return unexpectedError(err),
490491 }
491492 }
......@@ -501,6 +502,8 @@ pub const WriteFileError = error{
501502 /// The process cannot access the file because another process has locked
502503 /// a portion of the file.
503504 LockViolation,
505 /// The specified network name is no longer available.
506 ConnectionResetByPeer,
504507 Unexpected,
505508};
506509
......@@ -517,8 +520,8 @@ pub fn WriteFile(
517520 .InternalHigh = 0,
518521 .DUMMYUNIONNAME = .{
519522 .DUMMYSTRUCTNAME = .{
520 .Offset = @as(u32, @truncate(off)),
521 .OffsetHigh = @as(u32, @truncate(off >> 32)),
523 .Offset = @truncate(off),
524 .OffsetHigh = @truncate(off >> 32),
522525 },
523526 },
524527 .hEvent = null,
......@@ -536,6 +539,7 @@ pub fn WriteFile(
536539 .BROKEN_PIPE => return error.BrokenPipe,
537540 .INVALID_HANDLE => return error.NotOpenForWriting,
538541 .LOCK_VIOLATION => return error.LockViolation,
542 .NETNAME_DELETED => return error.ConnectionResetByPeer,
539543 else => |err| return unexpectedError(err),
540544 }
541545 }
lib/std/zig/system.zig-1
......@@ -1103,7 +1103,6 @@ fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
11031103 error.ConnectionResetByPeer => return error.UnableToReadElfFile,
11041104 error.ConnectionTimedOut => return error.UnableToReadElfFile,
11051105 error.SocketNotConnected => return error.UnableToReadElfFile,
1106 error.NetNameDeleted => return error.UnableToReadElfFile,
11071106 error.Unexpected => return error.Unexpected,
11081107 error.InputOutput => return error.FileSystem,
11091108 error.AccessDenied => return error.Unexpected,