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

Unix sockets on redox #51553

Merged
merged 16 commits into from Jul 11, 2018
Merged

Unix sockets on redox #51553

merged 16 commits into from Jul 11, 2018

Conversation

jD91mZM2
Copy link
Contributor

This is done using the ipcd daemon. It's not exactly like unix sockets because there is not actually a physical file for the path, but it's close enough for a basic implementation :)
This allows mio-uds and tokio-uds to work with a few modifications as well, which is exciting!

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 14, 2018
@rust-highfive

This comment has been minimized.

/// ```
#[stable(feature = "unix_socket", since = "1.10.0")]
#[derive(Clone)]
pub struct SocketAddr;
Copy link
Member

Choose a reason for hiding this comment

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

This can be constructed by third party code - is that intended?

Copy link
Contributor Author

@jD91mZM2 jD91mZM2 Jun 14, 2018

Choose a reason for hiding this comment

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

Haven't thought about that at all. It's not really a problem, so should I bother to fix it? (Also, how? With a dummy variable?)

Copy link
Member

Choose a reason for hiding this comment

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

pub struct SocketAddr(()); is the standard approach.

/// };
/// let addr = socket.local_addr().expect("Couldn't get local address");
/// ```
#[stable(feature = "unix_socket", since = "1.10.0")]
Copy link
Member

Choose a reason for hiding this comment

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

Seems like these should be on their own feature gate. They definitely haven't been stable since 1.10!

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 copied the code from unix 😛. How do I make a feature gate?

/// let addr = socket.local_addr().expect("Couldn't get local address");
/// ```
#[stable(feature = "unix_socket", since = "1.10.0")]
pub fn local_addr(&self) -> io::Result<SocketAddr> {
Copy link
Member

Choose a reason for hiding this comment

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

Why are these methods defined if they never succeed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For compatibility with the unix interface. Anything using it will still compile, just maybe not work perfectly, depending on the error handling.

Copy link
Member

Choose a reason for hiding this comment

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

What kind of programs call methods like local_addr or set_write_timeout but don't care if the operation succeeds or not?

@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![stable(feature = "unix_socket", since = "1.10.0")]
#![stable(feature = "unix_socket_redox", since = "1.27.0")]
Copy link
Member

Choose a reason for hiding this comment

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

Stuff is always initially unstable when added to the standard library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, will fix. I'm just so excited to get this working 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I make a tracking issue for it and everything?

@pietroalbini
Copy link
Member

Ping from triage @sfackler! This PR needs your review.

/// # Examples
///
/// ```
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

os::unix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redox extensions are still under os::unix

Copy link
Member

Choose a reason for hiding this comment

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

Redox is considered a unix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like it, since it's re-exported to os::unix in mod.rs

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, so my previous impression was that it wasn't. It seems less reasonable to have a different API between redox and "normal" unix in that case. I guess it might be best to go back to having a matching API and just returning errors?

Having two copies of the public-facing bits of this seems pretty hard to deal with maintenance-wise though. I think we'll want to refactor to have a single unified public interface that wraps the Redox/non-Redox impls.

/// With a pathname:
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

os::unix

/// Without a pathname:
///
/// ```
/// use std::os::unix::net::UnixDatagram;
Copy link
Member

Choose a reason for hiding this comment

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

os::unix

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixStream;
Copy link
Member

Choose a reason for hiding this comment

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

os::unix

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixStream;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixStream;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixStream;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixStream;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// }
/// ```
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Ok(None)
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compatibility with the unix interface. Without it tokio-uds needs some extra cfg madness, meanwhile it works perfectly with it.

Copy link
Member

Choose a reason for hiding this comment

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

The documentation claims that this returns the value of the SO_ERROR option but that is not the case.

///
/// ```no_run
/// use std::thread;
/// use std::os::unix::net::{UnixStream, UnixListener};
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

^

/// # Examples
///
/// ```no_run
/// use std::os::unix::net::UnixListener;
Copy link
Member

Choose a reason for hiding this comment

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

^

///
/// ```no_run
/// use std::thread;
/// use std::os::unix::net::{UnixStream, UnixListener};
Copy link
Member

Choose a reason for hiding this comment

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

^

/// }
/// ```
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Ok(None)
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be removed.

///
/// ```no_run
/// use std::thread;
/// use std::os::unix::net::{UnixStream, UnixListener};
Copy link
Member

Choose a reason for hiding this comment

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

^

@jD91mZM2
Copy link
Contributor Author

jD91mZM2 commented Jul 6, 2018

Nothing in the interface is changing code-wise since everything is re-exported, but the docs might display it differently.

To clarify, I should revert the commit that merges the public side of the interfaces?

@@ -0,0 +1,731 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
Copy link
Member

Choose a reason for hiding this comment

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

Is this module included in sys_common or is this a stray file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stray file, good catch!

@@ -0,0 +1,354 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
Copy link
Member

Choose a reason for hiding this comment

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

Is this module included in sys/unix/ext or is this a stray file?

@alexcrichton
Copy link
Member

I'd personally be ok with this as-is, but I'll leave approving to @sfackler

@sfackler
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 11, 2018

📌 Commit 0b56e7f has been approved by sfackler

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2018
@bors
Copy link
Contributor

bors commented Jul 11, 2018

⌛ Testing commit 0b56e7f with merge 8784470...

bors added a commit that referenced this pull request Jul 11, 2018
Unix sockets on redox

This is done using the ipcd daemon. It's not exactly like unix sockets because there is not actually a physical file for the path, but it's close enough for a basic implementation :)
This allows mio-uds and tokio-uds to work with a few modifications as well, which is exciting!
@bors
Copy link
Contributor

bors commented Jul 11, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 11, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:49:37] warning: spurious network error (2 tries remaining): curl error: Couldn't resolve host 'github.com'
[01:49:37] ; class=Net (12)
[01:50:33] warning: spurious network error (1 tries remaining): curl error: Couldn't resolve host 'github.com'
[01:50:33] ; class=Net (12)
[01:51:29] error: failed to load source for a dependency on `rand`
[01:51:29] Caused by:
[01:51:29]   Unable to update registry `https://github.com/rust-lang/crates.io-index`
[01:51:29] 
[01:51:29] Caused by:
[01:51:29] Caused by:
[01:51:29]   failed to fetch `https://github.com/rust-lang/crates.io-index`
[01:51:29] 
[01:51:29] Caused by:
[01:51:29]   curl error: Couldn't resolve host 'github.com'
[01:51:29] ; class=Net (12)
[01:51:29] 
[01:51:29] 
[01:51:29] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "generate-lockfile" "--manifest-path" "/checkout/obj/build/tmp/distcheck-src/rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"
[01:51:29] 
[01:51:29] 
[01:51:29] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[01:51:29] Build completed unsuccessfully in 1:48:36
---
travis_time:end:107ed913:start=1531291444480539795,finish=1531291444488798003,duration=8258208
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01d74c20
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0e635a16
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:49:37] warning: spurious network error (2 tries remaining): curl error: Couldn't resolve host 'github.com'
[01:49:37] ; class=Net (12)
[01:50:33] warning: spurious network error (1 tries remaining): curl error: Couldn't resolve host 'github.com'
[01:50:33] ; class=Net (12)
[01:51:29] error: failed to load source for a dependency on `rand`
[01:51:29] Caused by:
[01:51:29]   Unable to update registry `https://github.com/rust-lang/crates.io-index`
[01:51:29] 
[01:51:29] Caused by:
[01:51:29] Caused by:
[01:51:29]   failed to fetch `https://github.com/rust-lang/crates.io-index`
[01:51:29] 
[01:51:29] Caused by:
[01:51:29]   curl error: Couldn't resolve host 'github.com'
[01:51:29] ; class=Net (12)
[01:51:29] 
[01:51:29] 
[01:51:29] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "generate-lockfile" "--manifest-path" "/checkout/obj/build/tmp/distcheck-src/rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"
[01:51:29] 
[01:51:29] 
[01:51:29] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[01:51:29] Build completed unsuccessfully in 1:48:36
---
travis_time:end:107ed913:start=1531291444480539795,finish=1531291444488798003,duration=8258208
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01d74c20
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0e635a16
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@jD91mZM2
Copy link
Contributor Author

Looks like network errors, shouldn't be related to my changes

@pietroalbini
Copy link
Member

@bors retry travis-ci/travis-ci#9696

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2018
@bors
Copy link
Contributor

bors commented Jul 11, 2018

⌛ Testing commit 0b56e7f with merge 66787e0...

bors added a commit that referenced this pull request Jul 11, 2018
Unix sockets on redox

This is done using the ipcd daemon. It's not exactly like unix sockets because there is not actually a physical file for the path, but it's close enough for a basic implementation :)
This allows mio-uds and tokio-uds to work with a few modifications as well, which is exciting!
@bors
Copy link
Contributor

bors commented Jul 11, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: sfackler
Pushing 66787e0 to master...

@bors bors merged commit 0b56e7f into rust-lang:master Jul 11, 2018
@jD91mZM2
Copy link
Contributor Author

jD91mZM2 commented Jul 22, 2018

Should I make a stabilization issue/PR for unix_socket_redox? I have no idea how this stuff works, this is my first PR

@alexcrichton
Copy link
Member

For platform-specific modules there's not really much process, and especially if these APIs match the rest of libstd then it should be fine to just send a PR to stabilize them

@jD91mZM2
Copy link
Contributor Author

Awesome, thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants