Skip to content

Commit

Permalink
Adapt aio to the world of async/await, and fix some potential unsound…
Browse files Browse the repository at this point in the history
…ness.

* libc::aiocb must not be moved while the kernel has a pointer to it.
  This change enforces that requirement by using std::pin.

* Split LioCbBuilder out of LioCb.  struct LioCb relied on the
  (incorrect) assumption that a Vec's elements have a stable location in
  memory.  That's not true; they can be moved during Vec::push.  The
  solution is to use a Vec in the new Builder struct, but finalize it to
  a boxed slice (which doesn't support push) before allowing it to be
  submitted to the kernel.

* Eliminate owned buffer types.  mio-aio no longer uses owned buffers
  with nix::aio.  There's little need for it in the world of
  async/await.  I'm not aware of any other consumers.  This
  substantially simplifies the code.
  • Loading branch information
asomers committed May 30, 2021
1 parent 9f1b35b commit 5ac876e
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 552 deletions.
14 changes: 7 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ task:
image: freebsd-11-4-release-amd64
setup_script:
- fetch https://sh.rustup.rs -o rustup.sh
- sh rustup.sh -y --profile=minimal --default-toolchain 1.40.0
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- $HOME/.cargo/bin/rustup target add i686-unknown-freebsd
amd64_test_script:
- . $HOME/.cargo/env
Expand Down Expand Up @@ -46,7 +46,7 @@ task:
image: catalina-xcode
setup_script:
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
- sh rustup.sh -y --profile=minimal --default-toolchain 1.40.0
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- . $HOME/.cargo/env
- bash ci/install.sh
script:
Expand Down Expand Up @@ -101,7 +101,7 @@ task:
setup_script:
- mkdir /tmp/home
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
- sh rustup.sh -y --profile=minimal --default-toolchain 1.40.0
- sh rustup.sh -y --profile=minimal --default-toolchain 1.41.0
- . $HOME/.cargo/env
- bash ci/install.sh
script:
Expand All @@ -119,13 +119,13 @@ task:
- name: Linux x86_64
env:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: 1.40.0
TOOLCHAIN: 1.41.0
- name: Linux x86_64 musl
env:
TARGET: x86_64-unknown-linux-musl
TOOLCHAIN: 1.40.0
TOOLCHAIN: 1.41.0
container:
image: rust:1.40
image: rust:1.41
setup_script:
- rustup toolchain install $TOOLCHAIN
- rustup target add --toolchain $TOOLCHAIN $TARGET
Expand Down Expand Up @@ -173,7 +173,7 @@ task:
env:
TARGET: x86_64-fuchsia
container:
image: rust:1.40
image: rust:1.41
setup_script:
- rustup target add $TARGET
script:
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1429](https://github.com/nix-rust/nix/pull/1429))
- Made `Uid::is_root` a `const fn`
(#[1429](https://github.com/nix-rust/nix/pull/1429))
- `AioCb` is now always pinned. Once a `libc::aiocb` gets sent to the kernel,
its address in memory must not change. Nix now enforces that by using
`std::pin`. Most users won't need to change anything, except when using
`aio_suspend`. See that method's documentation for the new usage.
(#[1440](https://github.com/nix-rust/nix/pull/1440))
- `LioCb` is now constructed using a distinct `LioCbBuilder` struct. This
avoids a soundness issue with the old `LioCb`. Usage is similar but
construction now uses the builder pattern. See the documentation for
details.
(#[1440](https://github.com/nix-rust/nix/pull/1440))
- Minimum supported Rust version is now 1.41.0.
([#1440](https://github.com/nix-rust/nix/pull/1440))

### Fixed
- Allow `sockaddr_ll` size, as reported by the Linux kernel, to be smaller then it's definition
Expand All @@ -28,6 +40,11 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Removed `sys::socket::accept4` from Android arm because libc removed it in
version 0.2.87.
([#1399](https://github.com/nix-rust/nix/pull/1399))
- `AioCb::from_boxed_slice` and `AioCb::from_boxed_mut_slice` have been
removed. They were useful with earlier versions of Rust, but should no
longer be needed now that async/await are available. `AioCb`s now work
exclusively with borrowed buffers, not owned ones.
(#[1440](https://github.com/nix-rust/nix/pull/1440))

## [0.20.0] - 20 February 2021
### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ memoffset = "0.6.3"
cc = "1"

[dev-dependencies]
bytes = "0.4.8"
assert-impl = "0.1"
lazy_static = "1.2"
rand = "0.8"
tempfile = "3.2.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Tier 3:

## Usage

`nix` requires Rust 1.40.0 or newer.
`nix` requires Rust 1.41.0 or newer.

To use `nix`, add this to your `Cargo.toml`:

Expand Down
Loading

0 comments on commit 5ac876e

Please sign in to comment.