Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ libp2p-identify = { version = "0.47.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.12" }
libp2p-kad = { version = "0.49.0", path = "protocols/kad" }
libp2p-mdns = { version = "0.48.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.5.0", path = "misc/memory-connection-limits" }
libp2p-memory-connection-limits = { version = "0.5.1", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.17.0", path = "misc/metrics" }
libp2p-mplex = { version = "0.43.1", path = "muxers/mplex" }
libp2p-noise = { version = "0.46.1", path = "transports/noise" }
Expand Down
4 changes: 4 additions & 0 deletions misc/memory-connection-limits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1

- fix limit checking according to documentation, limit should be reached not exceeded.
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX).
## 0.5.0

<!-- Update to libp2p-swarm v0.47.0 -->
Expand Down
2 changes: 1 addition & 1 deletion misc/memory-connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-memory-connection-limits"
edition.workspace = true
rust-version = { workspace = true }
description = "Memory usage based connection limits for libp2p."
version = "0.5.0"
version = "0.5.1"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
Expand Down
2 changes: 1 addition & 1 deletion misc/memory-connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl Behaviour {
fn check_limit(&mut self) -> Result<(), ConnectionDenied> {
self.refresh_memory_stats_if_needed();

if self.process_physical_memory_bytes > self.max_allowed_bytes {
if self.process_physical_memory_bytes >= self.max_allowed_bytes {
return Err(ConnectionDenied::new(MemoryUsageLimitExceeded {
process_physical_memory_bytes: self.process_physical_memory_bytes,
max_allowed_bytes: self.max_allowed_bytes,
Expand Down
2 changes: 1 addition & 1 deletion misc/memory-connection-limits/tests/max_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use util::*;
#[tokio::test]
async fn max_bytes() {
const CONNECTION_LIMIT: usize = 20;
let max_allowed_bytes = CONNECTION_LIMIT * 1024 * 1024;
let max_allowed_bytes = (CONNECTION_LIMIT - 1) * 1024 * 1024;

let mut network = Swarm::new_ephemeral_tokio(|_| TestBehaviour {
connection_limits: Behaviour::with_max_bytes(max_allowed_bytes),
Expand Down
2 changes: 1 addition & 1 deletion misc/memory-connection-limits/tests/max_percentage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async fn max_percentage() {

// Adds current mem usage to the limit and update
let current_mem = memory_stats::memory_stats().unwrap().physical_mem;
let max_allowed_bytes = current_mem + CONNECTION_LIMIT * 1024 * 1024;
let max_allowed_bytes = current_mem + (CONNECTION_LIMIT - 1) * 1024 * 1024;
network.behaviour_mut().connection_limits = Behaviour::with_max_percentage(
max_allowed_bytes as f64 / system_info.total_memory() as f64,
);
Expand Down
Loading