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 from_std methods to TCP/Unix Stream/Listener #1124

Merged

Conversation

kleimkuhler
Copy link
Contributor

@kleimkuhler kleimkuhler commented Nov 6, 2019

Motivation

#1029 removed the from_std methods on the TCP (Unix) Stream (Listener)
resources. These methods are still needed in upstream libraries where creating
wrapped resources from standard types is needed.

Tokio: TcpListener::from_std

Signed-off-by: Kevin Leimkuhler kleimkuhler@icloud.com

@kleimkuhler kleimkuhler changed the title Kleimkuhler/listener from std Add from_std methods to TCP/Unix Stream/Listener Nov 6, 2019
@kleimkuhler kleimkuhler marked this pull request as ready for review November 6, 2019 05:02
@Thomasdezeeuw
Copy link
Collaborator

Can't this be implemented using FromRawFd in Tokio? I know the Windows trait FromRawSocket is missing, but is something we need to add.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@carllerche
Copy link
Member

@Thomasdezeeuw It's not critical to merge this, but IMO it is valuable to have an API for going from std -> mio in a portable way. Requiring going via raw conversions would require platform specific code.

Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

I'm not sure I entirely agree with the API, I think there will maybe misuses of it, but if upstream crates need it I'm OK with adding it.

src/net/tcp/listener.rs Outdated Show resolved Hide resolved
src/net/tcp/listener.rs Outdated Show resolved Hide resolved
src/net/tcp/stream.rs Outdated Show resolved Hide resolved
src/sys/unix/tcp/listener.rs Outdated Show resolved Hide resolved
src/sys/unix/tcp/listener.rs Outdated Show resolved Hide resolved
src/net/tcp/listener.rs Outdated Show resolved Hide resolved
tests/tcp_listener.rs Outdated Show resolved Hide resolved
tests/tcp_stream.rs Outdated Show resolved Hide resolved
src/sys/unix/tcp/listener.rs Outdated Show resolved Hide resolved
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler
Copy link
Contributor Author

@Thomasdezeeuw Thanks for the review. All your comments have been addressed. I added a lot more around tests; each I/O resource now have tests that test the from_std functions.

tests/tcp_stream.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

Some small things, but this almost ready to be merged.

tests/udp_socket.rs Show resolved Hide resolved
tests/uds.rs Outdated Show resolved Hide resolved
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@Thomasdezeeuw Thomasdezeeuw merged commit 2bda33f into tokio-rs:master Nov 8, 2019
@Thomasdezeeuw
Copy link
Collaborator

Thanks!

@kleimkuhler kleimkuhler deleted the kleimkuhler/listener-from-std branch November 8, 2019 18:50
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.

3 participants