aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/udp.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-02-01 18:36:31 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-02-01 18:36:31 +0800
commitf85212aa86c8feac17f582ac14f6b15260015261 (patch)
tree8f25667f7900b216ed27aec7ffb5504a695374eb /p2p/discover/udp.go
parentd951ff300e7c390d91b3fa34bec4424522ecf8a0 (diff)
parent2871781f64958c144a15ccb4e64c005a10be7cdd (diff)
downloaddexon-f85212aa86c8feac17f582ac14f6b15260015261.tar
dexon-f85212aa86c8feac17f582ac14f6b15260015261.tar.gz
dexon-f85212aa86c8feac17f582ac14f6b15260015261.tar.bz2
dexon-f85212aa86c8feac17f582ac14f6b15260015261.tar.lz
dexon-f85212aa86c8feac17f582ac14f6b15260015261.tar.xz
dexon-f85212aa86c8feac17f582ac14f6b15260015261.tar.zst
dexon-f85212aa86c8feac17f582ac14f6b15260015261.zip
Merge pull request #2146 from fjl/discover-win32-large-packets
p2p/discover: fix Windows-specific issue for larger-than-buffer packets
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