Skip to content

Commit 3d2a2f2

Browse files
committed
fix: preserve Unlimited StreamsInbound in connmgr reconciliation
Fixes ipfs#9695
1 parent 5b9442c commit 3d2a2f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/node/libp2p/rcmgr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,27 +459,31 @@ func ensureConnMgrMakeSenseVsResourceMgr(concreteLimits rcmgr.ConcreteLimitConfi
459459
return fmt.Errorf(`
460460
Unable to initialize libp2p due to conflicting resource manager limit configuration.
461461
resource manager System.Conns (%d) must be bigger than ConnMgr.HighWater (%d)
462+
See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr
462463
`, rcm.System.Conns, highWater)
463464
}
464465
if rcm.System.ConnsInbound != rcmgr.Unlimited && int64(rcm.System.ConnsInbound) <= highWater {
465466
// nolint
466467
return fmt.Errorf(`
467468
Unable to initialize libp2p due to conflicting resource manager limit configuration.
468469
resource manager System.ConnsInbound (%d) must be bigger than ConnMgr.HighWater (%d)
470+
See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr
469471
`, rcm.System.ConnsInbound, highWater)
470472
}
471473
if rcm.System.Streams != rcmgr.Unlimited && int64(rcm.System.Streams) <= highWater {
472474
// nolint
473475
return fmt.Errorf(`
474476
Unable to initialize libp2p due to conflicting resource manager limit configuration.
475477
resource manager System.Streams (%d) must be bigger than ConnMgr.HighWater (%d)
478+
See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr
476479
`, rcm.System.Streams, highWater)
477480
}
478481
if rcm.System.StreamsInbound != rcmgr.Unlimited && int64(rcm.System.StreamsInbound) <= highWater {
479482
// nolint
480483
return fmt.Errorf(`
481484
Unable to initialize libp2p due to conflicting resource manager limit configuration.
482485
resource manager System.StreamsInbound (%d) must be bigger than ConnMgr.HighWater (%d)
486+
See: https://github.com/ipfs/kubo/blob/master/docs/libp2p-resource-management.md#how-does-the-resource-manager-resourcemgr-relate-to-the-connection-manager-connmgr
483487
`, rcm.System.StreamsInbound, highWater)
484488
}
485489
return nil

core/node/libp2p/rcmgr_defaults.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ func createDefaultLimitConfig(cfg config.SwarmConfig) (limitConfig rcmgr.Concret
129129
}
130130

131131
// Scale System.StreamsInbound as well, but use the existing ratio of StreamsInbound to ConnsInbound
132-
partialLimits.System.StreamsInbound = rcmgr.LimitVal(maxInboundConns * int64(partialLimits.System.StreamsInbound) / int64(partialLimits.System.ConnsInbound))
132+
if partialLimits.System.StreamsInbound != rcmgr.Unlimited {
133+
partialLimits.System.StreamsInbound = rcmgr.LimitVal(maxInboundConns * int64(partialLimits.System.StreamsInbound) / int64(partialLimits.System.ConnsInbound))
134+
}
133135
partialLimits.System.ConnsInbound = rcmgr.LimitVal(maxInboundConns)
134136
}
135137

0 commit comments

Comments
 (0)