Skip to content

Make sure into_raw_fd doesn't close the file descriptor - #148

Merged
bors[bot] merged 3 commits into
async-rs:masterfrom
yshui:master
Sep 8, 2019
Merged

bors[bot] merged 3 commits into
async-rs:masterfrom
yshui:master

Conversation

@yshui

@yshui yshui commented Sep 5, 2019

Copy link
Copy Markdown
Contributor

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.

@ghost ghost left a comment •

Copy link
Copy Markdown

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. :)

Comment thread src/net/driver/mod.rs Resolved
Comment thread src/net/driver/mod.rs Resolved
Co-Authored-By: Stjepan Glavina <[email protected]>
@yshui

yshui commented Sep 8, 2019

Copy link
Copy Markdown
Contributor Author

@stjepang Thanks. Applied

@ghost

ghost commented Sep 8, 2019

Copy link
Copy Markdown

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

bors Bot commented Sep 8, 2019

Copy link
Copy Markdown
Contributor

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