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 <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>
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

Lines changed: 3 additions & 0 deletions
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)