format
Some checks failed
CI / checks (push) Failing after 2m23s

This commit is contained in:
Alex Emmet 2026-07-15 01:53:48 +02:00
commit 203ef1adcc
10 changed files with 55 additions and 76 deletions

View file

@ -4,10 +4,10 @@ use crate::pipe::PipeReader;
use mtp_codec::CommunicationValue;
use mtp_common::CommunicationError;
use std::sync::Arc;
use tokio::sync::{mpsc, Mutex, Notify, RwLock, Semaphore};
use tokio::sync::{Mutex, Notify, RwLock, Semaphore, mpsc};
use tokio::time::{Duration, sleep, timeout};
use wtransport::Connection;
use tracing::{debug, info, instrument, trace};
use wtransport::Connection;
#[cfg(feature = "pipes")]
#[derive(Debug)]
@ -119,10 +119,7 @@ impl Policy {
self
}
pub fn with_max_concurrent_stream_tasks(
mut self,
max_concurrent_stream_tasks: usize,
) -> Self {
pub fn with_max_concurrent_stream_tasks(mut self, max_concurrent_stream_tasks: usize) -> Self {
self.max_concurrent_stream_tasks = max_concurrent_stream_tasks;
self
}
@ -619,9 +616,7 @@ impl Receiver {
policy.receiver_queue_capacity,
);
#[cfg(feature = "pipes")]
let (pipe_tx, pipe_rx) = mpsc::channel::<PipeReader>(
policy.receiver_queue_capacity,
);
let (pipe_tx, pipe_rx) = mpsc::channel::<PipeReader>(policy.receiver_queue_capacity);
#[cfg(not(feature = "pipes"))]
let (tx, rx) = mpsc::channel::<Result<CommunicationValue, CommunicationError>>(
policy.receiver_queue_capacity,
@ -659,7 +654,10 @@ impl Receiver {
let cap_full = tx.capacity() == 0;
if cap_full {
trace!(target = "mtp.transport", "accept loop paused: receiver queue full");
trace!(
target = "mtp.transport",
"accept loop paused: receiver queue full"
);
tokio::select! {
_ = close_rx.changed() => {
if close_rx.borrow().is_some() {

View file

@ -9,13 +9,10 @@ pub struct PipeWriter {
impl PipeWriter {
pub async fn finish(mut self) -> Result<(), mtp_common::CommunicationError> {
self.stream
.finish()
.await
.map_err(|e| {
log::warn!("[PipeWriter] finish failed: {e}");
mtp_common::CommunicationError::StreamWriteError(e)
})
self.stream.finish().await.map_err(|e| {
log::warn!("[PipeWriter] finish failed: {e}");
mtp_common::CommunicationError::StreamWriteError(e)
})
}
pub fn abort(&mut self) -> Result<(), wtransport::error::ClosedStream> {

View file

@ -228,9 +228,7 @@ async fn test_receiver_backpressure_with_small_queue() {
let mut h = start_test_host(cert_pem.clone(), key_pem).await;
let url = format!("https://127.0.0.1:{}", h.local_addr().port());
let policy = Policy::default().with_receiver_queue_capacity(1);
let (client_tx, client_rx) = connect(&url, Some(cert_pem), policy.clone())
.await
.unwrap();
let (client_tx, client_rx) = connect(&url, Some(cert_pem), policy.clone()).await.unwrap();
let (_host_tx, host_rx) = h.next().await.unwrap();
let tm = TypeMap::latest();
@ -242,13 +240,10 @@ async fn test_receiver_backpressure_with_small_queue() {
}
for i in 0..8u128 {
let received = tokio::time::timeout(
std::time::Duration::from_secs(5),
host_rx.receive(),
)
.await
.unwrap()
.unwrap();
let received = tokio::time::timeout(std::time::Duration::from_secs(5), host_rx.receive())
.await
.unwrap()
.unwrap();
assert_numbered_message(&received, CommunicationType::Ping, i, &tm);
}
@ -332,13 +327,10 @@ async fn test_semaphore_saturation_with_concurrent_streams() {
}
for i in 0..6u128 {
let received = tokio::time::timeout(
std::time::Duration::from_secs(5),
host_rx.receive(),
)
.await
.unwrap()
.unwrap();
let received = tokio::time::timeout(std::time::Duration::from_secs(5), host_rx.receive())
.await
.unwrap()
.unwrap();
assert_numbered_message(&received, CommunicationType::Ping, i, &tm);
}