syscall: avoid setting O_NONBLOCK needlessly by checking flags beforehand

Change-Id: I097a2941f1d1a7fd98ccf1534940d03f47ac3229
Reviewed-on: https://go-review.googlesource.com/c/go/+/517675
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
This commit is contained in:
Andy Pan 2023-08-09 21:13:50 +08:00 committed by Gopher Robot
parent d13f7aa0ae
commit 8ecdc4e593

View file

@ -107,6 +107,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
if err != nil {
return err
}
if (flag&O_NONBLOCK != 0) == nonblocking {
return nil
}
if nonblocking {
flag |= O_NONBLOCK
} else {