mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
unix: avoid setting O_NONBLOCK needlessly by checking flags beforehand
Change-Id: I227118221df469a677f3ff140ca7b94acb7f9571 Reviewed-on: https://go-review.googlesource.com/c/sys/+/517576 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
@@ -549,6 +549,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 {
|
||||
|
||||
Reference in New Issue
Block a user