mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
pipeline read discv5
Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
parent
001565b087
commit
6617c338d8
1 changed files with 8 additions and 2 deletions
|
|
@ -619,9 +619,15 @@ func (t *UDPv5) dispatch() {
|
|||
t.send(r.destID, r.destAddr, r.msg, nil)
|
||||
|
||||
case p := <-t.packetInCh:
|
||||
// Arm next read immediately to allow pipelining.
|
||||
// The readLoop can start reading the next packet while this one is being handled.
|
||||
// Backpressure is still maintained by packetInCh (buffer 1) and readNextCh (buffer 1).
|
||||
select {
|
||||
case t.readNextCh <- struct{}{}:
|
||||
case <-t.closeCtx.Done(): // Avoid blocking on send if closing
|
||||
return
|
||||
}
|
||||
t.handlePacket(p.Data, p.Addr)
|
||||
// Arm next read.
|
||||
t.readNextCh <- struct{}{}
|
||||
|
||||
case <-t.closeCtx.Done():
|
||||
close(t.readNextCh)
|
||||
|
|
|
|||
Loading…
Reference in a new issue