Skip to content

Commit 8fe7146

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 8fe7146

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/unix.rs

+12-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,11 @@ 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 processesdoes so it cannot support
35+
/// non-blocking mode.
36+
///
37+
/// If it is set to `Some`, then It can only go from `Some(false)` -> `Some(true)` but not
38+
/// the other way around, since that could cause a race condition.
3239
is_non_blocking: Option<AtomicBool>,
3340
}
3441

@@ -115,6 +122,9 @@ impl Client {
115122
let path = Path::new(path_str);
116123

117124
let open_file = || {
125+
// Open with read write is necessary, since open with read-only or
126+
// write-only could block the thread until another thread open it
127+
// with write-only or read-only (or RDWR) correspondingly.
118128
OpenOptions::new()
119129
.read(true)
120130
.write(true)

0 commit comments

Comments
 (0)