Fix broadcast collection: UDP reader blocks until deadline, 500ms timeout everywhere
This commit is contained in:
@@ -118,17 +118,20 @@ func (t *udpTransport) SetReadTimeout(timeout time.Duration) {
|
||||
}
|
||||
|
||||
func (t *udpTransport) Reader() io.Reader {
|
||||
for {
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *udpTransport) Read(p []byte) (int, error) {
|
||||
if t.buf.Len() > 0 {
|
||||
return &t.buf
|
||||
return t.buf.Read(p)
|
||||
}
|
||||
pkt := make([]byte, 1500)
|
||||
n, err := t.conn.Read(pkt)
|
||||
if err != nil {
|
||||
return &t.buf
|
||||
return 0, err
|
||||
}
|
||||
t.buf.Write(pkt[:n])
|
||||
}
|
||||
return t.buf.Read(p)
|
||||
}
|
||||
|
||||
func (t *udpTransport) Broadcast() bool { return t.broadcast }
|
||||
|
||||
Reference in New Issue
Block a user