mirror of
https://github.com/LemmyNet/activitypub-federation-rust
synced 2024-11-13 23:47:07 +00:00
Fix request_counter check because fetch_add returns original value (#97)
This commit is contained in:
parent
9b31a7b44b
commit
da28c9c890
1 changed files with 3 additions and 1 deletions
|
@ -89,7 +89,9 @@ async fn fetch_object_http_with_accept<T: Clone, Kind: DeserializeOwned>(
|
||||||
config.verify_url_valid(url).await?;
|
config.verify_url_valid(url).await?;
|
||||||
info!("Fetching remote object {}", url.to_string());
|
info!("Fetching remote object {}", url.to_string());
|
||||||
|
|
||||||
let counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
|
let mut counter = data.request_counter.fetch_add(1, Ordering::SeqCst);
|
||||||
|
// fetch_add returns old value so we need to increment manually here
|
||||||
|
counter += 1;
|
||||||
if counter > config.http_fetch_limit {
|
if counter > config.http_fetch_limit {
|
||||||
return Err(Error::RequestLimit);
|
return Err(Error::RequestLimit);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue