Browse Source

Merge pull request #3837 from ruseinov/v0.31.8

V0.31.8
release/v0.31.8
Ethan Buchman 5 years ago
committed by GitHub
parent
commit
fe54b3323c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 6 deletions
  1. +3
    -0
      CHANGELOG_PENDING.md
  2. +11
    -1
      abci/server/socket_server.go
  3. +24
    -5
      p2p/pex/pex_reactor.go

+ 3
- 0
CHANGELOG_PENDING.md View File

@ -17,5 +17,8 @@
### FEATURES: ### FEATURES:
### IMPROVEMENTS: ### IMPROVEMENTS:
- [abci] \#3809 Recover from application panics in `server/socket_server.go` to allow socket cleanup (@ruseinov)
### BUG FIXES: ### BUG FIXES:
- [p2p] \#3338 Prevent "sent next PEX request too soon" errors by not calling
ensurePeers outside of ensurePeersRoutine

+ 11
- 1
abci/server/socket_server.go View File

@ -146,6 +146,16 @@ func (s *SocketServer) waitForClose(closeConn chan error, connID int) {
func (s *SocketServer) handleRequests(closeConn chan error, conn net.Conn, responses chan<- *types.Response) { func (s *SocketServer) handleRequests(closeConn chan error, conn net.Conn, responses chan<- *types.Response) {
var count int var count int
var bufReader = bufio.NewReader(conn) var bufReader = bufio.NewReader(conn)
defer func() {
// make sure to recover from any app-related panics to allow proper socket cleanup
r := recover()
if r != nil {
closeConn <- fmt.Errorf("recovered from panic: %v", r)
s.appMtx.Unlock()
}
}()
for { for {
var req = &types.Request{} var req = &types.Request{}
@ -154,7 +164,7 @@ func (s *SocketServer) handleRequests(closeConn chan error, conn net.Conn, respo
if err == io.EOF { if err == io.EOF {
closeConn <- err closeConn <- err
} else { } else {
closeConn <- fmt.Errorf("Error reading message: %v", err.Error())
closeConn <- fmt.Errorf("error reading message: %v", err)
} }
return return
} }


+ 24
- 5
p2p/pex/pex_reactor.go View File

@ -340,6 +340,15 @@ func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
if err != nil { if err != nil {
return err return err
} }
srcIsSeed := false
for _, seedAddr := range r.seedAddrs {
if seedAddr.Equals(srcAddr) {
srcIsSeed = true
break
}
}
for _, netAddr := range addrs { for _, netAddr := range addrs {
// Validate netAddr. Disconnect from a peer if it sends us invalid data. // Validate netAddr. Disconnect from a peer if it sends us invalid data.
if netAddr == nil { if netAddr == nil {
@ -365,13 +374,23 @@ func (r *PEXReactor) ReceiveAddrs(addrs []*p2p.NetAddress, src Peer) error {
} }
// If this address came from a seed node, try to connect to it without // If this address came from a seed node, try to connect to it without
// waiting.
for _, seedAddr := range r.seedAddrs {
if seedAddr.Equals(srcAddr) {
r.ensurePeers()
}
// waiting (#2093)
if srcIsSeed {
r.Logger.Info("Will dial address, which came from seed", "addr", netAddr, "seed", srcAddr)
go func(addr *p2p.NetAddress) {
err := r.dialPeer(addr)
if err != nil {
switch err.(type) {
case errMaxAttemptsToDial, errTooEarlyToDial:
r.Logger.Debug(err.Error(), "addr", addr)
default:
r.Logger.Error(err.Error(), "addr", addr)
}
}
}(netAddr)
} }
} }
return nil return nil
} }


Loading…
Cancel
Save