Skip to content

Commit 0119e16

Browse files
NobodyXuweihanglo
andcommitted
Add more comment
Co-authored-by: Weihang Lo <[email protected]> Signed-off-by: Jiahao XU <[email protected]>
1 parent d9c22a6 commit 0119e16

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/unix.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use std::thread::{self, Builder, JoinHandle};
1717
use std::time::Duration;
1818

1919
#[derive(Debug)]
20+
/// This preserves the `--jobserver-auth` type at creation time,
21+
/// so auth type will be passed down to and inherit from sub-Make processes correctly.
22+
///
23+
/// See <https://github.com/rust-lang/jobserver-rs/issues/99> for details.
2024
enum ClientCreationArg {
2125
Fds { read: c_int, write: c_int },
2226
Fifo(Box<Path>),
@@ -27,8 +31,12 @@ pub struct Client {
2731
read: File,
2832
write: File,
2933
creation_arg: ClientCreationArg,
30-
/// it can only go from Some(false) -> Some(true) but not the other way around, since that
31-
/// could cause a race condition.
34+
/// It is set to `None` if the pipe is shared with other processes, so it
35+
/// cannot support non-blocking mode.
36+
///
37+
/// If it is set to `Some`, then it can only go from
38+
/// `Some(false)` -> `Some(true)` but not the other way around,
39+
/// since that could cause a race condition.
3240
is_non_blocking: Option<AtomicBool>,
3341
}
3442

@@ -115,6 +123,10 @@ impl Client {
115123
let path = Path::new(path_str);
116124

117125
let open_file = || {
126+
// Opening with read write is necessary, since opening with
127+
// read-only or write-only could block the thread until another
128+
// thread opens it with write-only or read-only (or RDWR)
129+
// correspondingly.
118130
OpenOptions::new()
119131
.read(true)
120132
.write(true)

0 commit comments

Comments
 (0)