manage fds together with connss

This commit is contained in:
vyzo
2021-12-29 19:21:19 +02:00
parent a6f536861c
commit 3973696b28
2 changed files with 47 additions and 149 deletions

View File

@@ -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
}