Merge remote-tracking branch 'core/master' into new-crate

This commit is contained in:
Carl Lerche
2018-01-26 14:50:41 -08:00
5 changed files with 58 additions and 18 deletions
+3 -3
View File
@@ -3,18 +3,17 @@ sudo: false
matrix:
include:
- rust: 1.21.0
- rust: stable
- os: osx
- rust: beta
- rust: nightly
- rust: nightly
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- cargo doc --no-deps --all-features
after_success:
- travis-cargo doc-upload
- travis-cargo --only nightly doc-upload
script:
- cargo test
@@ -23,6 +22,7 @@ env:
global:
- secure: iwlN1zfUCp/5BAAheqIRSFIqiM9zSwfIGcVDw/V7jHveqXyNzmCs7H58/cd90WLqonqpPX0t5GF66oTjms4v0DFjgXr/k4358qeSZaV082V3baNrVpCDHeCQV0SvKsfiYxDDJGSUL1WIUP+tqqDm4+ksZQP3LnwZojkABjWz5CBNt4kX+Wz5ZbYqtQoxyuZba5UyPY2CXJtubvCVPGMJULuUpklYxXZ4dWM2olzGgVJ8rE8udhSZ4ER4JgxB0KUx3/5TwHHzgyPEsWR4bKN6JzBjIczQofXUcUXXdoZBs23H/VhCpzKcn3/oJ8btVYPzwtdj5FmVB1aVR/gjPo2bSGi/sofq+LwL/1HJXkM+kjl8m2dLLcDBKqNYNERtVA1++LhkMWAFRgGYe8v8Ryxjiue1NF5LgAIA/fjK0uI1DELTzTf/TKrM+AtPDNTvhOft4/YD+hoImjwk6nv6PBb2TiTYnc79Qf4AZ65tv1qtsAUPuw4plLaccHQAO4ldYVXn4u9c+iisJwvovs6jo06bF3U3qtdI5gXsrI9+T25TrXvYb+IREo0MHzYEM0KlPFnscEArzC3eajuSd36ARFP3lDc+gp2RPs89iJjowms0eRyepp7Cu6XO3Cd2pfAX8AqvnmttZf4Nm51ONeiBPXPXItUkJm49MCpMJywU1IZcWZg=
notifications:
email:
on_success: never
+3 -3
View File
@@ -19,15 +19,15 @@ appveyor = { repository = "alexcrichton/tokio" }
[dependencies]
bytes = "0.4"
log = "0.4"
mio = "0.6.11"
mio = "0.6.12"
slab = "0.4"
iovec = "0.1"
tokio-io = "0.1"
futures = "0.1.15"
futures = "0.1.16"
[dev-dependencies]
env_logger = { version = "0.4", default-features = false }
flate2 = { version = "0.2", features = ["tokio"] }
flate2 = { version = "1", features = ["tokio"] }
futures-cpupool = "0.1"
http = "0.1"
httparse = "1.0"
+1 -1
View File
@@ -88,7 +88,7 @@ fn compress(socket: TcpStream, pool: &CpuPool)
// done to ensure that all gz footers are written.
let (read, write) = socket.split();
let write = Count { io: write, amt: 0 };
let write = GzEncoder::new(write, flate2::Compression::Best);
let write = GzEncoder::new(write, flate2::Compression::best());
let process = io::copy(read, write).and_then(|(amt, _read, write)| {
io::shutdown(write).map(move |io| (amt, io.get_ref().amt))
});
+22 -6
View File
@@ -344,6 +344,27 @@ impl TcpStream {
self.io.get_ref().peer_addr()
}
/// Receives data on the socket from the remote address to which it is
/// connected, without removing that data from the queue. On success,
/// returns the number of bytes peeked.
///
/// Successive calls return the same data. This is accomplished by passing
/// `MSG_PEEK` as a flag to the underlying recv system call.
pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
if let Async::NotReady = self.poll_read() {
return Err(io::ErrorKind::WouldBlock.into())
}
match self.io.get_ref().peek(buf) {
Ok(v) => Ok(v),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
self.io.need_read()?;
Err(io::ErrorKind::WouldBlock.into())
}
Err(e) => Err(e),
}
}
/// Shuts down the read, write, or both halves of this connection.
///
/// This function will cause all pending and future I/O on the specified
@@ -616,12 +637,7 @@ impl<'a> AsyncWrite for &'a TcpStream {
// `bytes_vec` method.
static DUMMY: &[u8] = &[0];
let iovec = <&IoVec>::from(DUMMY);
let mut bufs = [
iovec, iovec, iovec, iovec,
iovec, iovec, iovec, iovec,
iovec, iovec, iovec, iovec,
iovec, iovec, iovec, iovec,
];
let mut bufs = [iovec; 64];
let n = buf.bytes_vec(&mut bufs);
self.io.get_ref().write_bufs(&bufs[..n])
};
+29 -5
View File
@@ -455,12 +455,14 @@ mod platform {
use mio::Ready;
use mio::unix::UnixReady;
pub fn aio() -> Ready {
UnixReady::aio().into()
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
pub fn all() -> Ready {
hup() | UnixReady::aio().into()
}
#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd")))]
pub fn all() -> Ready {
hup() | aio()
hup()
}
pub fn hup() -> Ready {
@@ -471,10 +473,20 @@ mod platform {
const ERROR: usize = 1 << 3;
const AIO: usize = 1 << 4;
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
fn is_aio(ready: &Ready) -> bool {
ready.is_aio()
}
#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd")))]
fn is_aio(_ready: &Ready) -> bool {
false
}
pub fn ready2usize(ready: Ready) -> usize {
let ready = UnixReady::from(ready);
let mut bits = 0;
if ready.is_aio() {
if is_aio(&ready) {
bits |= AIO;
}
if ready.is_error() {
@@ -486,10 +498,22 @@ mod platform {
bits
}
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios",
target_os = "macos"))]
fn usize2ready_aio(ready: &mut UnixReady) {
ready.insert(UnixReady::aio());
}
#[cfg(not(any(target_os = "dragonfly",
target_os = "freebsd", target_os = "ios", target_os = "macos")))]
fn usize2ready_aio(_ready: &mut UnixReady) {
// aio not available here → empty
}
pub fn usize2ready(bits: usize) -> Ready {
let mut ready = UnixReady::from(Ready::empty());
if bits & AIO != 0 {
ready.insert(UnixReady::aio());
usize2ready_aio(&mut ready);
}
if bits & HUP != 0 {
ready.insert(UnixReady::hup());