From e44b100654ca639d11221e547384f699e461296d Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Thu, 7 Oct 2021 17:37:50 -0700 Subject: add convenient wrapper for eventfd The same create/write/read pattern is copied around several places. It's easier to understand in a package with names and comments, and we can reuse the smart blocking code in package rawfile. PiperOrigin-RevId: 401647108 --- pkg/tcpip/link/sharedmem/tx.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pkg/tcpip/link/sharedmem/tx.go') diff --git a/pkg/tcpip/link/sharedmem/tx.go b/pkg/tcpip/link/sharedmem/tx.go index 5ffcb8ab4..35e5bff12 100644 --- a/pkg/tcpip/link/sharedmem/tx.go +++ b/pkg/tcpip/link/sharedmem/tx.go @@ -18,6 +18,7 @@ import ( "math" "golang.org/x/sys/unix" + "gvisor.dev/gvisor/pkg/eventfd" "gvisor.dev/gvisor/pkg/tcpip/buffer" "gvisor.dev/gvisor/pkg/tcpip/link/sharedmem/queue" ) @@ -32,7 +33,7 @@ type tx struct { q queue.Tx ids idManager bufs bufferManager - eventFD int + eventFD eventfd.Eventfd sharedDataFD int } @@ -148,7 +149,7 @@ func (t *tx) transmit(bufs ...buffer.View) bool { // notify writes to the tx.eventFD to indicate to the peer that there is data to // be read. func (t *tx) notify() { - unix.Write(t.eventFD, []byte{1, 0, 0, 0, 0, 0, 0, 0}) + t.eventFD.Notify() } // getBuffer returns a memory region mapped to the full contents of the given -- cgit v1.2.3