aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/udp.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-01-22 23:08:23 +0800
committerFelix Lange <fjl@twurst.com>2016-01-23 06:44:25 +0800
commit2871781f64958c144a15ccb4e64c005a10be7cdd (patch)
tree9a02049b55ffee03bb0f4fb97bb1c4b4b21f42d6 /p2p/discover/udp.go
parent78f196409552466ff878a030e4069495a923c73e (diff)
downloaddexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar.gz
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar.bz2
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar.lz
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar.xz
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.tar.zst
dexon-2871781f64958c144a15ccb4e64c005a10be7cdd.zip
p2p/discover: fix Windows-specific issue for larger-than-buffer packets
On Windows, UDPConn.ReadFrom returns an error for packets larger than the receive buffer. The error is not marked temporary, causing our loop to exit when the first oversized packet arrived. The fix is to treat this particular error as temporary. Fixes: #1579, #2087 Updates: #2082
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r--p2p/discover/udp.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 72b2a45e5..cec9046a3 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -453,8 +453,11 @@ func encodePacket(priv *ecdsa.PrivateKey, ptype byte, req interface{}) ([]byte,
return packet, nil
}
-type tempError interface {
- Temporary() bool
+func isTemporaryError(err error) bool {
+ tempErr, ok := err.(interface {
+ Temporary() bool
+ })
+ return ok && tempErr.Temporary() || isPacketTooBig(err)
}
// readLoop runs in its own goroutine. it handles incoming UDP packets.
@@ -466,7 +469,7 @@ func (t *udp) readLoop() {
buf := make([]byte, 1280)
for {
nbytes, from, err := t.conn.ReadFromUDP(buf)
- if tempErr, ok := err.(tempError); ok && tempErr.Temporary() {
+ if isTemporaryError(err) {
// Ignore temporary read errors.
glog.V(logger.Debug).Infof("Temporary read error: %v", err)
continue