Skip to content

Commit

Permalink
fix: cap unlimited rpc connection (#4442)
Browse files Browse the repository at this point in the history
Description
---
Setting -1 to rpc max count was setting value usize::MAX which is over the actual limit.

How Has This Been Tested?
---
Manually.
  • Loading branch information
Cifko committed Aug 11, 2022
1 parent ae93885 commit 4f1a4fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion comms/core/src/protocol/rpc/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod mock;
mod router;
use std::{
borrow::Cow,
cmp,
convert::TryFrom,
future::Future,
io,
Expand Down Expand Up @@ -175,7 +176,7 @@ impl RpcServerBuilder {
}

pub fn with_maximum_simultaneous_sessions(mut self, limit: usize) -> Self {
self.maximum_simultaneous_sessions = Some(limit);
self.maximum_simultaneous_sessions = Some(cmp::min(limit, BoundedExecutor::max_theoretical_tasks()));
self
}

Expand Down Expand Up @@ -242,6 +243,7 @@ where
) -> Self {
Self {
executor: match config.maximum_simultaneous_sessions {
Some(usize::MAX) => BoundedExecutor::allow_maximum(),
Some(num) => BoundedExecutor::from_current(num),
None => BoundedExecutor::allow_maximum(),
},
Expand Down

0 comments on commit 4f1a4fe

Please sign in to comment.