mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge pull request #19064 from ziglang/fix-netname-deleted
std: map NETNAME_DELETED to error.ConnectionResetByPeer
This commit is contained in:
commit
6fddc9cd3d
4 changed files with 19 additions and 8 deletions
|
|
@ -142,6 +142,17 @@ test "HTTP server handles a chunked transfer coding request" {
|
||||||
const stream = try std.net.tcpConnectToHost(gpa, "127.0.0.1", test_server.port());
|
const stream = try std.net.tcpConnectToHost(gpa, "127.0.0.1", test_server.port());
|
||||||
defer stream.close();
|
defer stream.close();
|
||||||
try stream.writeAll(request_bytes);
|
try stream.writeAll(request_bytes);
|
||||||
|
|
||||||
|
const response = try stream.reader().readAllAlloc(gpa, 100);
|
||||||
|
defer gpa.free(response);
|
||||||
|
|
||||||
|
const expected_response =
|
||||||
|
"HTTP/1.1 200 OK\r\n" ++
|
||||||
|
"content-length: 21\r\n" ++
|
||||||
|
"content-type: text/plain\r\n" ++
|
||||||
|
"\r\n" ++
|
||||||
|
"message from server!\n";
|
||||||
|
try expectEqualStrings(expected_response, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "echo content server" {
|
test "echo content server" {
|
||||||
|
|
|
||||||
|
|
@ -836,9 +836,6 @@ pub const ReadError = error{
|
||||||
NotOpenForReading,
|
NotOpenForReading,
|
||||||
SocketNotConnected,
|
SocketNotConnected,
|
||||||
|
|
||||||
// Windows only
|
|
||||||
NetNameDeleted,
|
|
||||||
|
|
||||||
/// This error occurs when no global event loop is configured,
|
/// This error occurs when no global event loop is configured,
|
||||||
/// and reading from the file descriptor would block.
|
/// and reading from the file descriptor would block.
|
||||||
WouldBlock,
|
WouldBlock,
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,8 @@ pub fn FindClose(hFindFile: HANDLE) void {
|
||||||
|
|
||||||
pub const ReadFileError = error{
|
pub const ReadFileError = error{
|
||||||
BrokenPipe,
|
BrokenPipe,
|
||||||
NetNameDeleted,
|
/// The specified network name is no longer available.
|
||||||
|
ConnectionResetByPeer,
|
||||||
OperationAborted,
|
OperationAborted,
|
||||||
Unexpected,
|
Unexpected,
|
||||||
};
|
};
|
||||||
|
|
@ -485,7 +486,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64) ReadFileError!usiz
|
||||||
.OPERATION_ABORTED => continue,
|
.OPERATION_ABORTED => continue,
|
||||||
.BROKEN_PIPE => return 0,
|
.BROKEN_PIPE => return 0,
|
||||||
.HANDLE_EOF => return 0,
|
.HANDLE_EOF => return 0,
|
||||||
.NETNAME_DELETED => return error.NetNameDeleted,
|
.NETNAME_DELETED => return error.ConnectionResetByPeer,
|
||||||
else => |err| return unexpectedError(err),
|
else => |err| return unexpectedError(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -501,6 +502,8 @@ pub const WriteFileError = error{
|
||||||
/// The process cannot access the file because another process has locked
|
/// The process cannot access the file because another process has locked
|
||||||
/// a portion of the file.
|
/// a portion of the file.
|
||||||
LockViolation,
|
LockViolation,
|
||||||
|
/// The specified network name is no longer available.
|
||||||
|
ConnectionResetByPeer,
|
||||||
Unexpected,
|
Unexpected,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -517,8 +520,8 @@ pub fn WriteFile(
|
||||||
.InternalHigh = 0,
|
.InternalHigh = 0,
|
||||||
.DUMMYUNIONNAME = .{
|
.DUMMYUNIONNAME = .{
|
||||||
.DUMMYSTRUCTNAME = .{
|
.DUMMYSTRUCTNAME = .{
|
||||||
.Offset = @as(u32, @truncate(off)),
|
.Offset = @truncate(off),
|
||||||
.OffsetHigh = @as(u32, @truncate(off >> 32)),
|
.OffsetHigh = @truncate(off >> 32),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.hEvent = null,
|
.hEvent = null,
|
||||||
|
|
@ -536,6 +539,7 @@ pub fn WriteFile(
|
||||||
.BROKEN_PIPE => return error.BrokenPipe,
|
.BROKEN_PIPE => return error.BrokenPipe,
|
||||||
.INVALID_HANDLE => return error.NotOpenForWriting,
|
.INVALID_HANDLE => return error.NotOpenForWriting,
|
||||||
.LOCK_VIOLATION => return error.LockViolation,
|
.LOCK_VIOLATION => return error.LockViolation,
|
||||||
|
.NETNAME_DELETED => return error.ConnectionResetByPeer,
|
||||||
else => |err| return unexpectedError(err),
|
else => |err| return unexpectedError(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1103,7 +1103,6 @@ fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
|
||||||
error.ConnectionResetByPeer => return error.UnableToReadElfFile,
|
error.ConnectionResetByPeer => return error.UnableToReadElfFile,
|
||||||
error.ConnectionTimedOut => return error.UnableToReadElfFile,
|
error.ConnectionTimedOut => return error.UnableToReadElfFile,
|
||||||
error.SocketNotConnected => return error.UnableToReadElfFile,
|
error.SocketNotConnected => return error.UnableToReadElfFile,
|
||||||
error.NetNameDeleted => return error.UnableToReadElfFile,
|
|
||||||
error.Unexpected => return error.Unexpected,
|
error.Unexpected => return error.Unexpected,
|
||||||
error.InputOutput => return error.FileSystem,
|
error.InputOutput => return error.FileSystem,
|
||||||
error.AccessDenied => return error.Unexpected,
|
error.AccessDenied => return error.Unexpected,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue