make it easy to toggle uring on/off

This commit is contained in:
Josh Bleecher Snyder 2021-06-03 15:55:27 -07:00
parent eff65381f2
commit fec66b4100
1 changed files with 6 additions and 1 deletions

View File

@ -568,7 +568,12 @@ func (t *Wrapper) write(buf []byte, offset int) (int, error) {
func (t *Wrapper) read(buf []byte, offset int) (n int, err error) {
// TODO: upstream has graceful shutdown error handling here.
buff := buf[offset-4:]
n, err = t.ring.Read(buff[:])
const useIOUring = false
if useIOUring {
n, err = t.ring.Read(buff[:])
} else {
n, err = t.tdev.(*wgtun.NativeTun).File().Read(buff[:])
}
if errors.Is(err, syscall.EBADFD) {
err = os.ErrClosed
}