1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

Use immutable reference of service state. Update awc dns resolver. (#1905)

This commit is contained in:
fakeshadow
2021-02-06 17:00:40 -08:00
committed by GitHub
parent 20cf0094e5
commit 41bc04b1c4
65 changed files with 497 additions and 538 deletions

View File

@ -21,7 +21,7 @@ impl<T> WsService<T> {
WsService(Arc::new(Mutex::new((PhantomData, Cell::new(false)))))
}
fn set_polled(&mut self) {
fn set_polled(&self) {
*self.0.lock().unwrap().1.get_mut() = true;
}
@ -44,15 +44,12 @@ where
type Error = Error;
type Future = Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn poll_ready(&mut self, _ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&self, _ctx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.set_polled();
Poll::Ready(Ok(()))
}
fn call(
&mut self,
(req, mut framed): (Request, Framed<T, h1::Codec>),
) -> Self::Future {
fn call(&self, (req, mut framed): (Request, Framed<T, h1::Codec>)) -> Self::Future {
let fut = async move {
let res = ws::handshake(req.head()).unwrap().message_body(());