Skip to content

Conversation

yshui
Copy link
Contributor

@yshui yshui commented Sep 5, 2019

Closes #147

Previously all of the into_raw_fd implementations only returns a copy of
the inner RawFd, while still holding the ownership of the file
descriptor when returning for into_raw_fd. Since `self` is dropped at
the end of into_raw_fd, the returned file descriptor will actually be
closed, render the function unuseable.

The patch makes sure that into_raw_fd actually takes the ownership of
the file descriptor all the way from the inner IoHandle. To achieve
this, I have to use an Option in IoHandle to store the I/O source. It's
not pretty, but I cannot come up with a better way.
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks! I've only left suggestions for small adjustments to comments. :)

Co-Authored-By: Stjepan Glavina <[email protected]>
@yshui
Copy link
Contributor Author

yshui commented Sep 8, 2019

@stjepang Thanks. Applied

@ghost
Copy link

ghost commented Sep 8, 2019

bors r+

bors bot added a commit that referenced this pull request Sep 8, 2019
148: Make sure into_raw_fd doesn't close the file descriptor r=stjepang a=yshui

Closes #147 

Co-authored-by: Yuxuan Shui <[email protected]>
Co-authored-by: yshui <[email protected]>
@bors
Copy link
Contributor

bors bot commented Sep 8, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit 8e2bf24 into async-rs:master Sep 8, 2019
bors bot added a commit that referenced this pull request Sep 8, 2019
165: Fix a bug in conversion of File into raw handle r=stjepang a=stjepang

Same bugfix as #148, but applied to `async_std::fs::File`.

Co-authored-by: Stjepan Glavina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

socket closed after UnixStream::into_raw_fd()
1 participant