Patchwork D8443: rust-chg: have attach_io() simply take reference of AsRawFd object

login
register
mail settings
Submitter phabricator
Date April 23, 2020, 6:02 p.m.
Message ID <814700cad4ef99557c10f6b25dfc8d4c@localhost.localdomain>
Download mbox | patch
Permalink /patch/46213/
State Not Applicable
Headers show

Comments

phabricator - April 23, 2020, 6:02 p.m.
Herald added a subscriber: mercurial-patches.
Closed by commit rHGcb5822e6e545: rust-chg: have attach_io() simply take reference of AsRawFd object (authored by yuja).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8443?vs=21120&id=21187

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8443/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8443

AFFECTED FILES
  rust/chg/src/attachio.rs

CHANGE DETAILS




To: yuja, #hg-reviewers, Alphare
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/chg/src/attachio.rs b/rust/chg/src/attachio.rs
--- a/rust/chg/src/attachio.rs
+++ b/rust/chg/src/attachio.rs
@@ -21,14 +21,12 @@ 
 /// 3. Client sends fds with 1-byte dummy payload in response.
 /// 4. Server returns the number of the fds received.
 ///
-/// If the stderr is omitted, it will be redirected to the stdout. This
-/// allows us to attach the pager stdin to both stdout and stderr, and
-/// dispose of the client-side handle once attached.
+/// The client-side fds may be dropped once duplicated to the server.
 pub async fn attach_io(
     proto: &mut Protocol<impl Connection + AsRawFd>,
-    stdin: impl AsRawFd,
-    stdout: impl AsRawFd,
-    stderr: Option<impl AsRawFd>,
+    stdin: &impl AsRawFd,
+    stdout: &impl AsRawFd,
+    stderr: &impl AsRawFd,
 ) -> io::Result<()> {
     // TODO: unindent
     {
@@ -56,7 +54,7 @@ 
                     let sock_fd = proto.as_raw_fd();
                     let ifd = stdin.as_raw_fd();
                     let ofd = stdout.as_raw_fd();
-                    let efd = stderr.as_ref().map_or(ofd, |f| f.as_raw_fd());
+                    let efd = stderr.as_raw_fd();
                     procutil::send_raw_fds(sock_fd, &[ifd, ofd, efd])?;
                 }
                 ChannelMessage::InputRequest(..)