]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #12855 : alexcrichton/rust/shutdown, r=brson
authorbors <bors@rust-lang.org>
Fri, 14 Mar 2014 04:06:34 +0000 (21:06 -0700)
committerbors <bors@rust-lang.org>
Fri, 14 Mar 2014 04:06:34 +0000 (21:06 -0700)
This is something that is plausibly useful, and is provided by libuv. This is
not currently surfaced as part of the `TcpStream` type, but it may possibly
appear in the future. For now only the raw functionality is provided through the
Rtio objects.

1  2 
src/librustuv/net.rs
src/libstd/io/net/tcp.rs
src/libstd/libc.rs
src/libstd/rt/rtio.rs

Simple merge
index edadbc7873ac04087f526c340e9c1b7ca7def208,95be3add0db95a644ff0d134a7bb9fc624ee589a..7b1dd114d348f716940d12b0f400806d427219ac
@@@ -708,7 -749,25 +708,25 @@@ mod test 
          });
          s1.write([2]).unwrap();
  
 -        p.recv();
 +        rx.recv();
      })
+     iotest!(fn shutdown_smoke() {
+         use rt::rtio::RtioTcpStream;
+         let addr = next_test_ip4();
+         let a = TcpListener::bind(addr).unwrap().listen();
+         spawn(proc() {
+             let mut a = a;
+             let mut c = a.accept().unwrap();
+             assert_eq!(c.read_to_end(), Ok(~[]));
+             c.write([1]).unwrap();
+         });
+         let mut s = TcpStream::connect(addr).unwrap();
+         assert!(s.obj.close_write().is_ok());
+         assert!(s.write([1]).is_err());
+         assert_eq!(s.read_to_end(), Ok(~[1]));
+     })
  }
  
Simple merge
Simple merge