authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2020-11-30 18:49:41+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-30 20:00:26-08:00
log92ec24f77c6c146fd9943a41b055603ff1e442a5
tree36f99ea3a65d2a787a0908b51544a0625e6e1c5f
parent21565ca991bba9692ed74ec9fb9a665f8e504c7f

std/os: remove unneeded error from accept errorset

POSIX compliant fnctl cannot return EPERM when getting/setting the given flags. See the specification here: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html

2 files changed, 4 insertions(+), 8 deletions(-)

lib/std/net.zig-4
...@@ -1661,10 +1661,6 @@ pub const StreamServer = struct {...@@ -1661,10 +1661,6 @@ pub const StreamServer = struct {
1661 /// Firewall rules forbid connection.1661 /// Firewall rules forbid connection.
1662 BlockedByFirewall,1662 BlockedByFirewall,
16631663
1664 /// Permission to create a socket of the specified type and/or
1665 /// protocol is denied.
1666 PermissionDenied,
1667
1668 FileDescriptorNotASocket,1664 FileDescriptorNotASocket,
16691665
1670 ConnectionResetByPeer,1666 ConnectionResetByPeer,
lib/std/os.zig+4-4
...@@ -2942,10 +2942,6 @@ pub const AcceptError = error{...@@ -2942,10 +2942,6 @@ pub const AcceptError = error{
2942 /// and accepting from the socket would block.2942 /// and accepting from the socket would block.
2943 WouldBlock,2943 WouldBlock,
29442944
2945 /// Permission to create a socket of the specified type and/or
2946 /// protocol is denied.
2947 PermissionDenied,
2948
2949 /// An incoming connection was indicated, but was subsequently terminated by the2945 /// An incoming connection was indicated, but was subsequently terminated by the
2950 /// remote peer prior to accepting the call.2946 /// remote peer prior to accepting the call.
2951 ConnectionResetByPeer,2947 ConnectionResetByPeer,
...@@ -4130,12 +4126,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4130,12 +4126,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4130 var fd_flags = fcntl(sock, F_GETFD, 0) catch |err| switch (err) {4126 var fd_flags = fcntl(sock, F_GETFD, 0) catch |err| switch (err) {
4131 error.FileBusy => unreachable,4127 error.FileBusy => unreachable,
4132 error.Locked => unreachable,4128 error.Locked => unreachable,
4129 error.PermissionDenied => unreachable,
4133 else => |e| return e,4130 else => |e| return e,
4134 };4131 };
4135 fd_flags |= FD_CLOEXEC;4132 fd_flags |= FD_CLOEXEC;
4136 _ = fcntl(sock, F_SETFD, fd_flags) catch |err| switch (err) {4133 _ = fcntl(sock, F_SETFD, fd_flags) catch |err| switch (err) {
4137 error.FileBusy => unreachable,4134 error.FileBusy => unreachable,
4138 error.Locked => unreachable,4135 error.Locked => unreachable,
4136 error.PermissionDenied => unreachable,
4139 else => |e| return e,4137 else => |e| return e,
4140 };4138 };
4141 }4139 }
...@@ -4156,12 +4154,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {...@@ -4156,12 +4154,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
4156 var fl_flags = fcntl(sock, F_GETFL, 0) catch |err| switch (err) {4154 var fl_flags = fcntl(sock, F_GETFL, 0) catch |err| switch (err) {
4157 error.FileBusy => unreachable,4155 error.FileBusy => unreachable,
4158 error.Locked => unreachable,4156 error.Locked => unreachable,
4157 error.PermissionDenied => unreachable,
4159 else => |e| return e,4158 else => |e| return e,
4160 };4159 };
4161 fl_flags |= O_NONBLOCK;4160 fl_flags |= O_NONBLOCK;
4162 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {4161 _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {
4163 error.FileBusy => unreachable,4162 error.FileBusy => unreachable,
4164 error.Locked => unreachable,4163 error.Locked => unreachable,
4164 error.PermissionDenied => unreachable,
4165 else => |e| return e,4165 else => |e| return e,
4166 };4166 };
4167 }4167 }