Skip to content

Commit 7221138

Browse files
authored
errors!: s/ConnectionReset/ConnectionResetByPeer/g (#155)
The kqueue and epoll backends forward errors from zig. The zig error name for a Connection Reset is ConnectionResetByPeer. Use this name for libxev defined errors which semantically mean the same thing. This prevents users of the library from needing to check the backend before handling a ConnectionResetByPeer error.
2 parents 982e8ad + 24f65a8 commit 7221138

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/backend/io_uring.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ pub const Completion = struct {
709709
else switch (@as(posix.E, @enumFromInt(-res))) {
710710
.CANCELED => error.Canceled,
711711
.PIPE => error.BrokenPipe,
712-
.CONNRESET => error.ConnectionReset,
712+
.CONNRESET => error.ConnectionResetByPeer,
713713
else => |errno| posix.unexpectedErrno(errno),
714714
},
715715
},
@@ -720,7 +720,7 @@ pub const Completion = struct {
720720
else switch (@as(posix.E, @enumFromInt(-res))) {
721721
.CANCELED => error.Canceled,
722722
.PIPE => error.BrokenPipe,
723-
.CONNRESET => error.ConnectionReset,
723+
.CONNRESET => error.ConnectionResetByPeer,
724724
else => |errno| posix.unexpectedErrno(errno),
725725
},
726726
},
@@ -819,7 +819,7 @@ pub const Completion = struct {
819819

820820
return switch (@as(posix.E, @enumFromInt(-res))) {
821821
.CANCELED => error.Canceled,
822-
.CONNRESET => error.ConnectionReset,
822+
.CONNRESET => error.ConnectionResetByPeer,
823823
else => |errno| posix.unexpectedErrno(errno),
824824
};
825825
}
@@ -1074,7 +1074,7 @@ pub const ReadError = error{
10741074
EOF,
10751075
Canceled,
10761076
Unexpected,
1077-
ConnectionReset,
1077+
ConnectionResetByPeer,
10781078
};
10791079

10801080
pub const ShutdownError = error{
@@ -1085,7 +1085,7 @@ pub const ShutdownError = error{
10851085
pub const WriteError = error{
10861086
Canceled,
10871087
BrokenPipe,
1088-
ConnectionReset,
1088+
ConnectionResetByPeer,
10891089
Unexpected,
10901090
};
10911091

src/backend/iocp.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ pub const Loop = struct {
624624
break :action switch (err) {
625625
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
626626
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .send = error.Canceled } },
627-
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .send = error.ConnectionReset } },
627+
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .send = error.ConnectionResetByPeer } },
628628
else => .{ .result = .{ .send = windows.unexpectedWSAError(err) } },
629629
};
630630
}
@@ -652,7 +652,7 @@ pub const Loop = struct {
652652
break :action switch (err) {
653653
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
654654
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .recv = error.Canceled } },
655-
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recv = error.ConnectionReset } },
655+
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recv = error.ConnectionResetByPeer } },
656656
else => .{ .result = .{ .recv = windows.unexpectedWSAError(err) } },
657657
};
658658
}
@@ -679,7 +679,7 @@ pub const Loop = struct {
679679
break :action switch (err) {
680680
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
681681
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .sendto = error.Canceled } },
682-
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .sendto = error.ConnectionReset } },
682+
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .sendto = error.ConnectionResetByPeer } },
683683
else => .{ .result = .{ .sendto = windows.unexpectedWSAError(err) } },
684684
};
685685
}
@@ -709,7 +709,7 @@ pub const Loop = struct {
709709
break :action switch (err) {
710710
windows.ws2_32.WinsockError.WSA_IO_PENDING => .{ .submitted = {} },
711711
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => .{ .result = .{ .recvfrom = error.Canceled } },
712-
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recvfrom = error.ConnectionReset } },
712+
.WSAECONNRESET, .WSAENETRESET => .{ .result = .{ .recvfrom = error.ConnectionResetByPeer } },
713713
else => .{ .result = .{ .recvfrom = windows.unexpectedWSAError(err) } },
714714
};
715715
}
@@ -1049,7 +1049,7 @@ pub const Completion = struct {
10491049
break :r .{
10501050
.send = switch (err) {
10511051
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
1052-
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
1052+
.WSAECONNRESET, .WSAENETRESET => error.ConnectionResetByPeer,
10531053
else => windows.unexpectedWSAError(err),
10541054
},
10551055
};
@@ -1068,7 +1068,7 @@ pub const Completion = struct {
10681068
break :r .{
10691069
.recv = switch (err) {
10701070
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
1071-
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
1071+
.WSAECONNRESET, .WSAENETRESET => error.ConnectionResetByPeer,
10721072
else => windows.unexpectedWSAError(err),
10731073
},
10741074
};
@@ -1103,7 +1103,7 @@ pub const Completion = struct {
11031103
break :r .{
11041104
.sendto = switch (err) {
11051105
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
1106-
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
1106+
.WSAECONNRESET, .WSAENETRESET => error.ConnectionResetByPeer,
11071107
else => windows.unexpectedWSAError(err),
11081108
},
11091109
};
@@ -1122,7 +1122,7 @@ pub const Completion = struct {
11221122
break :r .{
11231123
.recvfrom = switch (err) {
11241124
.WSA_OPERATION_ABORTED, .WSAECONNABORTED => error.Canceled,
1125-
.WSAECONNRESET, .WSAENETRESET => error.ConnectionReset,
1125+
.WSAECONNRESET, .WSAENETRESET => error.ConnectionResetByPeer,
11261126
else => windows.unexpectedWSAError(err),
11271127
},
11281128
};
@@ -1351,14 +1351,14 @@ pub const ShutdownError = posix.ShutdownError || error{
13511351

13521352
pub const WriteError = windows.WriteFileError || error{
13531353
Canceled,
1354-
ConnectionReset,
1354+
ConnectionResetByPeer,
13551355
Unexpected,
13561356
};
13571357

13581358
pub const ReadError = windows.ReadFileError || error{
13591359
EOF,
13601360
Canceled,
1361-
ConnectionReset,
1361+
ConnectionResetByPeer,
13621362
Unexpected,
13631363
};
13641364

0 commit comments

Comments
 (0)