mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 08:16:52 +01:00
udp: Fold buffer handoff into ListenOut
This commit is contained in:
1 parent
1fb77bdda5
commit
06035252b2
12 files changed
+45
-60
No files matched your search
+2
-9
@@ -396,13 +396,6 @@ type rxConn struct {
|
||||
swaps int
|
||||
}
|
||||
|
||||
func (c *rxConn) ListenOut(r udp.EncReader, flush func()) error {
|
||||
return c.ListenOutHandoff(r, func(bufs [][]byte) [][]byte {
|
||||
flush()
|
||||
return bufs
|
||||
})
|
||||
}
|
||||
|
||||
func (c *rxConn) HandoffShape() (n, size int) {
|
||||
n = c.batchLen
|
||||
for _, s := range c.sizes {
|
||||
@@ -411,7 +404,7 @@ func (c *rxConn) HandoffShape() (n, size int) {
|
||||
return n, udp.MTU
|
||||
}
|
||||
|
||||
func (c *rxConn) ListenOutHandoff(r udp.EncReader, handoff func(bufs [][]byte) [][]byte) error {
|
||||
func (c *rxConn) ListenOut(r udp.EncReader, handoff func(bufs [][]byte) [][]byte) error {
|
||||
n, _ := c.HandoffShape()
|
||||
bufs := make([][]byte, n)
|
||||
for i := range bufs {
|
||||
@@ -447,7 +440,7 @@ func (c *rxConn) ListenOutHandoff(r udp.EncReader, handoff func(bufs [][]byte) [
|
||||
return os.ErrClosed
|
||||
}
|
||||
|
||||
// plainConn hides ListenOutHandoff, so it cannot hand off its batches.
|
||||
// plainConn hides HandoffShape, so receive stays inline.
|
||||
type plainConn struct{ udp.Conn }
|
||||
|
||||
var rxBatches = metrics.GetOrRegisterCounter("flow.rx.batches", nil)
|
||||
|
||||
Reference in new issue
Block a user