mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Extract handle_connection out of do_serve
This commit is contained in:
+27
-10
@@ -304,6 +304,33 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handle_connection(&mut make_service, &signal_tx, &close_rx, io, remote_addr).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
drop(close_rx);
|
||||||
|
drop(listener);
|
||||||
|
|
||||||
|
trace!(
|
||||||
|
"waiting for {} task(s) to finish",
|
||||||
|
close_tx.receiver_count()
|
||||||
|
);
|
||||||
|
close_tx.closed().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_connection<L, M, S>(
|
||||||
|
make_service: &mut M,
|
||||||
|
signal_tx: &watch::Sender<()>,
|
||||||
|
close_rx: &watch::Receiver<()>,
|
||||||
|
io: <L as Listener>::Io,
|
||||||
|
remote_addr: <L as Listener>::Addr,
|
||||||
|
) where
|
||||||
|
L: Listener,
|
||||||
|
L::Addr: Debug,
|
||||||
|
M: for<'a> Service<IncomingStream<'a, L>, Error = Infallible, Response = S> + Send + 'static,
|
||||||
|
for<'a> <M as Service<IncomingStream<'a, L>>>::Future: Send,
|
||||||
|
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
|
||||||
|
S::Future: Send,
|
||||||
|
{
|
||||||
let io = TokioIo::new(io);
|
let io = TokioIo::new(io);
|
||||||
|
|
||||||
trace!("connection {remote_addr:?} accepted");
|
trace!("connection {remote_addr:?} accepted");
|
||||||
@@ -353,16 +380,6 @@ where
|
|||||||
|
|
||||||
drop(close_rx);
|
drop(close_rx);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
drop(close_rx);
|
|
||||||
drop(listener);
|
|
||||||
|
|
||||||
trace!(
|
|
||||||
"waiting for {} task(s) to finish",
|
|
||||||
close_tx.receiver_count()
|
|
||||||
);
|
|
||||||
close_tx.closed().await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An incoming stream.
|
/// An incoming stream.
|
||||||
|
|||||||
Reference in New Issue
Block a user