Skip to content

Commit

Permalink
Fix broken CI, improve inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunicorn committed Jul 4, 2024
1 parent 2911fa4 commit 52c5387
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/matrix-sdk/src/http_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(crate) const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(30);
#[derive(Clone, Debug)]
struct MaybeSemaphore(Arc<Option<Semaphore>>);

#[allow(dead_code)] // holding this until drop is all we are doing
#[allow(dead_code)] // false-positive lint: we never use it but only hold it for the drop
struct MaybeSemaphorePermit<'a>(Option<SemaphorePermit<'a>>);

impl MaybeSemaphore {
Expand All @@ -65,7 +65,8 @@ impl MaybeSemaphore {
async fn acquire(&self) -> MaybeSemaphorePermit<'_> {
match self.0.as_ref() {
Some(inner) => {
// ignoring errors as we never close this
// This can only ever error if the semaphore was closed,
// which we never do, so we can safely ignore any error case
MaybeSemaphorePermit(inner.acquire().await.ok())
}
None => MaybeSemaphorePermit(None),
Expand Down Expand Up @@ -397,7 +398,7 @@ mod tests {
});

// give it some time to issue the requests
tokio::time::sleep(Duration::from_millis(300)).await;
tokio::time::sleep(Duration::from_secs(1)).await;

assert_eq!(counter.load(Ordering::SeqCst), 254, "Not all requests passed through");
bg_task.abort();
Expand Down

0 comments on commit 52c5387

Please sign in to comment.