| ... | @@ -6479,33 +6479,31 @@ pub const PollError = error{ | ... | @@ -6479,33 +6479,31 @@ pub const PollError = error{ |
| 6479 | } || UnexpectedError; | 6479 | } || UnexpectedError; |
| 6480 | | 6480 | |
| 6481 | pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { | 6481 | pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { |
| | 6482 | if (native_os == .windows) { |
| | 6483 | switch (windows.poll(fds.ptr, @intCast(fds.len), timeout)) { |
| | 6484 | windows.ws2_32.SOCKET_ERROR => switch (windows.ws2_32.WSAGetLastError()) { |
| | 6485 | .WSANOTINITIALISED => unreachable, |
| | 6486 | .WSAENETDOWN => return error.NetworkSubsystemFailed, |
| | 6487 | .WSAENOBUFS => return error.SystemResources, |
| | 6488 | // TODO: handle more errors |
| | 6489 | else => |err| return windows.unexpectedWSAError(err), |
| | 6490 | }, |
| | 6491 | else => |rc| return @intCast(rc), |
| | 6492 | } |
| | 6493 | } |
| 6482 | while (true) { | 6494 | while (true) { |
| 6483 | const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources; | 6495 | const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources; |
| 6484 | const rc = system.poll(fds.ptr, fds_count, timeout); | 6496 | const rc = system.poll(fds.ptr, fds_count, timeout); |
| 6485 | if (native_os == .windows) { | 6497 | switch (errno(rc)) { |
| 6486 | if (rc == windows.ws2_32.SOCKET_ERROR) { | 6498 | .SUCCESS => return @intCast(rc), |
| 6487 | switch (windows.ws2_32.WSAGetLastError()) { | 6499 | .FAULT => unreachable, |
| 6488 | .WSANOTINITIALISED => unreachable, | 6500 | .INTR => continue, |
| 6489 | .WSAENETDOWN => return error.NetworkSubsystemFailed, | 6501 | .INVAL => unreachable, |
| 6490 | .WSAENOBUFS => return error.SystemResources, | 6502 | .NOMEM => return error.SystemResources, |
| 6491 | // TODO: handle more errors | 6503 | else => |err| return unexpectedErrno(err), |
| 6492 | else => |err| return windows.unexpectedWSAError(err), | | |
| 6493 | } | | |
| 6494 | } else { | | |
| 6495 | return @intCast(rc); | | |
| 6496 | } | | |
| 6497 | } else { | | |
| 6498 | switch (errno(rc)) { | | |
| 6499 | .SUCCESS => return @intCast(rc), | | |
| 6500 | .FAULT => unreachable, | | |
| 6501 | .INTR => continue, | | |
| 6502 | .INVAL => unreachable, | | |
| 6503 | .NOMEM => return error.SystemResources, | | |
| 6504 | else => |err| return unexpectedErrno(err), | | |
| 6505 | } | | |
| 6506 | } | 6504 | } |
| 6507 | unreachable; | | |
| 6508 | } | 6505 | } |
| | 6506 | unreachable; |
| 6509 | } | 6507 | } |
| 6510 | | 6508 | |
| 6511 | pub const PPollError = error{ | 6509 | pub const PPollError = error{ |