Skip to content

Commit 552c4e8

Browse files
panjf2000gopherbot
authored andcommitted
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 <[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]>
1 parent ee57887 commit 552c4e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

unix/syscall_unix.go

+3
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
549549
if err != nil {
550550
return err
551551
}
552+
if (flag&O_NONBLOCK != 0) == nonblocking {
553+
return nil
554+
}
552555
if nonblocking {
553556
flag |= O_NONBLOCK
554557
} else {

0 commit comments

Comments
 (0)