mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 06:53:46 +00:00
fixes go test
This commit is contained in:
parent
77e6dc181c
commit
80e20e6386
1 changed files with 11 additions and 16 deletions
|
|
@ -1151,27 +1151,25 @@ func (p *PortalProtocol) handleFindContent(id enode.ID, addr *net.UDPAddr, reque
|
||||||
var conn *utp.Conn
|
var conn *utp.Conn
|
||||||
var connectCtx context.Context
|
var connectCtx context.Context
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
defer func(clsConn *utp.Conn) {
|
defer func() {
|
||||||
p.connIdGen.Remove(connId)
|
p.connIdGen.Remove(connId)
|
||||||
if clsConn == nil {
|
if conn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := clsConn.Close()
|
err := conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Log.Error("failed to close connection", "err", err)
|
p.Log.Error("failed to close connection", "err", err)
|
||||||
}
|
}
|
||||||
}(conn)
|
}()
|
||||||
connectCtx, cancel = context.WithTimeout(bctx, defaultUTPConnectTimeout)
|
|
||||||
defer func(cancelFunc context.CancelFunc) {
|
|
||||||
cancelFunc()
|
|
||||||
}(cancel)
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-bctx.Done():
|
case <-bctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
p.Log.Debug("will accept find content conn from: ", "source", addr, "connId", connId)
|
p.Log.Debug("will accept find content conn from: ", "source", addr, "connId", connId)
|
||||||
|
connectCtx, cancel = context.WithTimeout(bctx, defaultUTPConnectTimeout)
|
||||||
conn, err = p.utp.AcceptUTPContext(connectCtx, connectionId.SendId())
|
conn, err = p.utp.AcceptUTPContext(connectCtx, connectionId.SendId())
|
||||||
|
cancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if metrics.Enabled {
|
if metrics.Enabled {
|
||||||
p.portalMetrics.utpOutFailConn.Inc(1)
|
p.portalMetrics.utpOutFailConn.Inc(1)
|
||||||
|
|
@ -1285,26 +1283,23 @@ func (p *PortalProtocol) handleOffer(id enode.ID, addr *net.UDPAddr, request *po
|
||||||
var conn *utp.Conn
|
var conn *utp.Conn
|
||||||
var connectCtx context.Context
|
var connectCtx context.Context
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
defer func(clsConn *utp.Conn) {
|
defer func() {
|
||||||
p.connIdGen.Remove(connId)
|
p.connIdGen.Remove(connId)
|
||||||
if clsConn == nil {
|
if conn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := clsConn.Close()
|
err := conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Log.Error("failed to close connection", "err", err)
|
p.Log.Error("failed to close connection", "err", err)
|
||||||
}
|
}
|
||||||
}(conn)
|
}()
|
||||||
connectCtx, cancel = context.WithTimeout(bctx, defaultUTPConnectTimeout)
|
|
||||||
defer func(cancelFunc context.CancelFunc) {
|
|
||||||
cancelFunc()
|
|
||||||
}(cancel)
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-bctx.Done():
|
case <-bctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
p.Log.Debug("will accept offer conn from: ", "source", addr, "connId", connId)
|
p.Log.Debug("will accept offer conn from: ", "source", addr, "connId", connId)
|
||||||
|
connectCtx, cancel = context.WithTimeout(bctx, defaultUTPConnectTimeout)
|
||||||
conn, err = p.utp.AcceptUTPContext(connectCtx, connectionId.SendId())
|
conn, err = p.utp.AcceptUTPContext(connectCtx, connectionId.SendId())
|
||||||
cancel()
|
cancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue