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 <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Run-TryBot: Andy Pan <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
  • 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.