Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Windows system error codes that should map to io::ErrorKind::TimedOut #71756

Merged
merged 4 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libstd/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ pub enum ErrorKind {
#[stable(feature = "rust1", since = "1.0.0")]
Interrupted,
/// Any I/O error not part of this list.
///
/// Errors that are `Other` now may move to a different or a new
/// [`ErrorKind`] variant in the future. It is not recommended to match
/// an error against `Other` and to expect any additional characteristics,
/// e.g., a specific [`Error::raw_os_error`] return value.
#[stable(feature = "rust1", since = "1.0.0")]
Other,

Expand Down
17 changes: 15 additions & 2 deletions src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,26 @@ pub const ERROR_FILE_EXISTS: DWORD = 80;
pub const ERROR_INVALID_PARAMETER: DWORD = 87;
pub const ERROR_BROKEN_PIPE: DWORD = 109;
pub const ERROR_CALL_NOT_IMPLEMENTED: DWORD = 120;
pub const ERROR_SEM_TIMEOUT: DWORD = 121;
carstenandrich marked this conversation as resolved.
Show resolved Hide resolved
pub const ERROR_INSUFFICIENT_BUFFER: DWORD = 122;
pub const ERROR_ALREADY_EXISTS: DWORD = 183;
pub const ERROR_NO_DATA: DWORD = 232;
pub const ERROR_ENVVAR_NOT_FOUND: DWORD = 203;
pub const ERROR_NO_DATA: DWORD = 232;
pub const ERROR_DRIVER_CANCEL_TIMEOUT: DWORD = 594;
pub const ERROR_OPERATION_ABORTED: DWORD = 995;
pub const ERROR_IO_PENDING: DWORD = 997;
pub const ERROR_TIMEOUT: DWORD = 0x5B4;
pub const ERROR_SERVICE_REQUEST_TIMEOUT: DWORD = 1053;
pub const ERROR_COUNTER_TIMEOUT: DWORD = 1121;
pub const ERROR_TIMEOUT: DWORD = 1460;
pub const ERROR_RESOURCE_CALL_TIMED_OUT: DWORD = 5910;
pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: DWORD = 7012;
pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: DWORD = 7040;
pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: DWORD = 8014;
pub const ERROR_DS_TIMELIMIT_EXCEEDED: DWORD = 8226;
pub const DNS_ERROR_RECORD_TIMED_OUT: DWORD = 9705;
pub const ERROR_IPSEC_IKE_TIMED_OUT: DWORD = 13805;
pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: DWORD = 15402;
pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: DWORD = 15403;

pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT;

Expand Down
15 changes: 15 additions & 0 deletions src/libstd/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,22 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
c::ERROR_FILE_NOT_FOUND => return ErrorKind::NotFound,
c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound,
c::ERROR_NO_DATA => return ErrorKind::BrokenPipe,
c::ERROR_SEM_TIMEOUT => return ErrorKind::TimedOut,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use or pattern here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just changed and pushed it. I initially decided against using the or pattern, because it isn't used for ErrorKind::NotFound, either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe because it is too short to worth using the or pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it easier to read with the or pattern. Do you think it makes sense to also use it for NotFound to ensure uniform style?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to run tidy on the new commit. Fix is in progress ...

Copy link
Contributor

@tesuji tesuji May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a favor. Better let to official reviewers.

c::WAIT_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_DRIVER_CANCEL_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_OPERATION_ABORTED => return ErrorKind::TimedOut,
c::ERROR_SERVICE_REQUEST_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_COUNTER_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_RESOURCE_CALL_TIMED_OUT => return ErrorKind::TimedOut,
c::ERROR_CTX_MODEM_RESPONSE_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_CTX_CLIENT_QUERY_TIMEOUT => return ErrorKind::TimedOut,
c::FRS_ERR_SYSVOL_POPULATE_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_DS_TIMELIMIT_EXCEEDED => return ErrorKind::TimedOut,
c::DNS_ERROR_RECORD_TIMED_OUT => return ErrorKind::TimedOut,
c::ERROR_IPSEC_IKE_TIMED_OUT => return ErrorKind::TimedOut,
c::ERROR_RUNLEVEL_SWITCH_TIMEOUT => return ErrorKind::TimedOut,
c::ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT => return ErrorKind::TimedOut,
_ => {}
}

Expand Down