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

It's not clear when try_clone calls can fail #45536

Closed
achanda opened this issue Oct 25, 2017 · 6 comments
Closed

It's not clear when try_clone calls can fail #45536

achanda opened this issue Oct 25, 2017 · 6 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. P-medium Medium priority

Comments

@achanda
Copy link
Contributor

achanda commented Oct 25, 2017

Some types have a try_clone methods that returns Result<T>. From the documentation, it is not clear under what conditions can this call fail. Types that implement it are

https://doc.rust-lang.org/std/?search=try_clone

@sfackler sfackler added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Oct 25, 2017
@cuviper
Copy link
Member

cuviper commented Oct 26, 2017

The error conditions are OS-dependent, e.g. from Windows DuplicateHandle or Posix dup (or really fcntl F_DUPFD_CLOEXEC).

@retep998
Copy link
Member

Because try_clone creates a new handle or file descriptor, any sort of resource exhaustion which prevents another handle or file descriptor from being created can cause try_clone to fail.

@TimNN TimNN added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Oct 31, 2017
@steveklabnik steveklabnik added the P-medium Medium priority label Oct 31, 2017
@steveklabnik steveklabnik added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label May 29, 2018
@DevQps
Copy link
Contributor

DevQps commented Apr 9, 2019

@steveklabnik I guess this issue raises about the same questions as #40322 namely: "Should we be documenting platform specific behavior and error codes)?" Maybe we should ping the libs team for this one as well?

@pocesar
Copy link

pocesar commented Apr 10, 2019

for windows specifically for TcpStream:

Sockets. No error is returned, but the duplicate handle may not be recognized by Winsock at the target process. Also, using DuplicateHandle interferes with internal reference counting on the underlying object. To duplicate a socket handle, use the WSADuplicateSocket function.

@DevQps
Copy link
Contributor

DevQps commented Aug 8, 2019

@steveklabnik What do you think we should do with this? Personally I find it quite clear from the context that these methods can fail (since they deal with OS primitives like sockets and files). But adding extra information in what kind of contexts they could fail would mean adding platform-specific cases. Do you think that we can close this? Or do you believe we should append something to the currently existing docs?

@steveklabnik
Copy link
Member

Given this comment, I believe we should close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

8 participants