aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/udp.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-08-19 20:11:12 +0800
committerFelix Lange <fjl@twurst.com>2015-08-19 20:38:55 +0800
commit7d5ff770e22a3791c0f9c2794a19f59ca2756b33 (patch)
treeb421e8b9c8ce776d2c1d70c9261c6a78d27fec93 /p2p/discover/udp.go
parent3b997c3e169dc3dee8f41d9ece5341ef04d7eeaf (diff)
downloaddexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar.gz
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar.bz2
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar.lz
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar.xz
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.tar.zst
dexon-7d5ff770e22a3791c0f9c2794a19f59ca2756b33.zip
p2p/discover: continue reading after temporary errors
Might solve #1579
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r--p2p/discover/udp.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 008e63937..6aefb68f7 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -458,6 +458,10 @@ func encodePacket(priv *ecdsa.PrivateKey, ptype byte, req interface{}) ([]byte,
return packet, nil
}
+type tempError interface {
+ Temporary() bool
+}
+
// readLoop runs in its own goroutine. it handles incoming UDP packets.
func (t *udp) readLoop() {
defer t.conn.Close()
@@ -467,7 +471,13 @@ func (t *udp) readLoop() {
buf := make([]byte, 1280)
for {
nbytes, from, err := t.conn.ReadFromUDP(buf)
- if err != nil {
+ if tempErr, ok := err.(tempError); ok && tempErr.Temporary() {
+ // Ignore temporary read errors.
+ glog.V(logger.Debug).Infof("Temporary read error: %v", err)
+ continue
+ } else if err != nil {
+ // Shut down the loop for permament errors.
+ glog.V(logger.Debug).Infof("Read error: %v", err)
return
}
t.handlePacket(from, buf[:nbytes])