mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2026-08-22 19:43:28 +08:00
manage fds together with connss
This commit is contained in:
9
rcmgr.go
9
rcmgr.go
@@ -190,18 +190,11 @@ func (r *ResourceManager) getPeerScope(p peer.ID) *PeerScope {
|
||||
func (r *ResourceManager) OpenConnection(dir network.Direction, usefd bool) (network.ConnectionManagementScope, error) {
|
||||
conn := NewConnectionScope(dir, usefd, r.limits.GetConnLimits(), r)
|
||||
|
||||
if err := conn.AddConn(dir); err != nil {
|
||||
if err := conn.AddConn(dir, usefd); err != nil {
|
||||
conn.Done()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if usefd {
|
||||
if err := conn.AddFD(1); err != nil {
|
||||
conn.Done()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user