mirror of
https://github.com/golang/go
synced 2024-10-05 05:11:25 -06:00
76b724cc63
On the latest darwin kernels, kevent in runtime-integrated network poller sometimes reports SYN-SENT state sockets as ESTABLISHED ones, though it's still unclear what's the root cause. This change prevents such spurious notifications by additional connect system calls. Fixes #14548. Change-Id: Ie29788e38ca735ca77259befeba3229d6a30ac52 Reviewed-on: https://go-review.googlesource.com/20468 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
35 lines
672 B
Go
35 lines
672 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build !plan9,!windows
|
|
|
|
package net
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
var (
|
|
errTimedout = syscall.ETIMEDOUT
|
|
errOpNotSupported = syscall.EOPNOTSUPP
|
|
|
|
abortedConnRequestErrors = []error{syscall.ECONNABORTED} // see accept in fd_unix.go
|
|
)
|
|
|
|
func isPlatformError(err error) bool {
|
|
_, ok := err.(syscall.Errno)
|
|
return ok
|
|
}
|
|
|
|
func samePlatformError(err, want error) bool {
|
|
if op, ok := err.(*OpError); ok {
|
|
err = op.Err
|
|
}
|
|
if sys, ok := err.(*os.SyscallError); ok {
|
|
err = sys.Err
|
|
}
|
|
return err == want
|
|
}
|