mirror of
https://github.com/golang/go
synced 2024-11-23 09:50:03 -07:00
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:
parent
d13f7aa0ae
commit
8ecdc4e593
@ -107,6 +107,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if (flag&O_NONBLOCK != 0) == nonblocking {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if nonblocking {
|
if nonblocking {
|
||||||
flag |= O_NONBLOCK
|
flag |= O_NONBLOCK
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user