mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2026-08-22 19:43:28 +08:00
Fix allowlist system instantiation
This commit is contained in:
18
rcmgr.go
18
rcmgr.go
@@ -144,14 +144,14 @@ func NewResourceManager(limits Limiter, opts ...Option) (network.ResourceManager
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
r.system = newSystemScope(limits.GetSystemLimits(), r)
|
r.system = newSystemScope(limits.GetSystemLimits(), r, "system")
|
||||||
r.system.IncRef()
|
r.system.IncRef()
|
||||||
r.transient = newTransientScope(limits.GetTransientLimits(), r)
|
r.transient = newTransientScope(limits.GetTransientLimits(), r, "transient", r.system.resourceScope)
|
||||||
r.transient.IncRef()
|
r.transient.IncRef()
|
||||||
|
|
||||||
r.allowlistedSystem = newSystemScope(limits.GetSystemLimits(), r)
|
r.allowlistedSystem = newSystemScope(limits.GetSystemLimits(), r, "allowlistedSystem")
|
||||||
r.allowlistedSystem.IncRef()
|
r.allowlistedSystem.IncRef()
|
||||||
r.allowlistedTransient = newTransientScope(limits.GetTransientLimits(), r)
|
r.allowlistedTransient = newTransientScope(limits.GetTransientLimits(), r, "allowlistedTransient", r.allowlistedSystem.resourceScope)
|
||||||
r.allowlistedTransient.IncRef()
|
r.allowlistedTransient.IncRef()
|
||||||
|
|
||||||
r.cancelCtx, r.cancel = context.WithCancel(context.Background())
|
r.cancelCtx, r.cancel = context.WithCancel(context.Background())
|
||||||
@@ -384,17 +384,17 @@ func (r *resourceManager) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSystemScope(limit Limit, rcmgr *resourceManager) *systemScope {
|
func newSystemScope(limit Limit, rcmgr *resourceManager, name string) *systemScope {
|
||||||
return &systemScope{
|
return &systemScope{
|
||||||
resourceScope: newResourceScope(limit, nil, "system", rcmgr.trace, rcmgr.metrics),
|
resourceScope: newResourceScope(limit, nil, name, rcmgr.trace, rcmgr.metrics),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTransientScope(limit Limit, rcmgr *resourceManager) *transientScope {
|
func newTransientScope(limit Limit, rcmgr *resourceManager, name string, systemScope *resourceScope) *transientScope {
|
||||||
return &transientScope{
|
return &transientScope{
|
||||||
resourceScope: newResourceScope(limit,
|
resourceScope: newResourceScope(limit,
|
||||||
[]*resourceScope{rcmgr.system.resourceScope},
|
[]*resourceScope{systemScope},
|
||||||
"transient", rcmgr.trace, rcmgr.metrics),
|
name, rcmgr.trace, rcmgr.metrics),
|
||||||
system: rcmgr.system,
|
system: rcmgr.system,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user