Skip to content

Commit

Permalink
unix: avoid setting O_NONBLOCK needlessly by checking flags beforehand
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
panjf2000 authored and gopherbot committed Aug 10, 2023
1 parent ee57887 commit 552c4e8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions unix/syscall_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 552c4e8

Please sign in to comment.