1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 18:02:58 +01:00

mark some fn as unsafe

This commit is contained in:
Nikolay Kim 2019-07-17 11:16:38 +06:00
parent 23a230a83b
commit 42d526bced
4 changed files with 16 additions and 14 deletions

View File

@ -10,9 +10,9 @@ matrix:
include: include:
- rust: stable - rust: stable
- rust: beta - rust: beta
- rust: nightly-2019-03-02 - rust: nightly-2019-06-15
allow_failures: allow_failures:
- rust: nightly-2019-03-02 - rust: nightly-2019-06-15
env: env:
global: global:
@ -25,8 +25,8 @@ before_install:
- sudo apt-get install -y openssl libssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev - sudo apt-get install -y openssl libssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev
before_cache: | before_cache: |
if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-03-02" ]]; then if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-06-15" ]]; then
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install --version 0.6.11 cargo-tarpaulin
fi fi
# Add clippy # Add clippy
@ -35,14 +35,14 @@ before_script:
script: script:
- | - |
if [[ "$TRAVIS_RUST_VERSION" != "nightly-2019-03-02" ]]; then if [[ "$TRAVIS_RUST_VERSION" != "nightly-2019-06-15" ]]; then
cargo clean cargo clean
cargo test --all --all-features -- --nocapture cargo test --all --all-features -- --nocapture
fi fi
after_success: after_success:
- | - |
if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-03-02" ]]; then if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-06-15" ]]; then
taskset -c 0 cargo tarpaulin --all --all-features --out Xml taskset -c 0 cargo tarpaulin --all --all-features --out Xml
echo "Uploaded code coverage" echo "Uploaded code coverage"
bash <(curl -s https://codecov.io/bash) bash <(curl -s https://codecov.io/bash)

View File

@ -1,5 +1,5 @@
# Changes # Changes
## [0.1.0] - 2019-xx-xx ## [0.1.0] - 2019-07-17
* Initial release * Initial release

View File

@ -29,7 +29,7 @@ impl<T> Cell<T> {
} }
} }
pub fn get_mut(&mut self) -> &mut T { pub(crate) unsafe fn get_mut(&mut self) -> &mut T {
unsafe { &mut *self.inner.as_ref().get() } &mut *self.inner.as_ref().get()
} }
} }

View File

@ -153,7 +153,7 @@ where
}; };
let mut cell = self.inner.clone(); let mut cell = self.inner.clone();
cell.get_mut().task.register(); unsafe { cell.get_mut().task.register() };
tokio_current_thread::spawn( tokio_current_thread::spawn(
self.service self.service
.call(Item::new(self.state.clone(), self.sink.clone(), item)) .call(Item::new(self.state.clone(), self.sink.clone(), item))
@ -163,9 +163,11 @@ where
Ok(None) => return Ok(()), Ok(None) => return Ok(()),
Err(err) => Err(err), Err(err) => Err(err),
}; };
let inner = cell.get_mut(); unsafe {
inner.buf.push_back(item); let inner = cell.get_mut();
inner.task.notify(); inner.buf.push_back(item);
inner.task.notify();
}
Ok(()) Ok(())
}), }),
); );
@ -181,7 +183,7 @@ where
/// write to framed object /// write to framed object
fn poll_write(&mut self) -> bool { fn poll_write(&mut self) -> bool {
let inner = self.inner.get_mut(); let inner = unsafe { self.inner.get_mut() };
let mut rx_done = self.rx.is_none(); let mut rx_done = self.rx.is_none();
let mut buf_empty = inner.buf.is_empty(); let mut buf_empty = inner.buf.is_empty();
loop { loop {