Skip to content

Commit

Permalink
move unix.EINPROGRESS condition to err nil block
Browse files Browse the repository at this point in the history
  • Loading branch information
cscps committed May 23, 2022
1 parent 483cff9 commit 4331027
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions internal/socket/tcp_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ func tcpSocket(proto, addr string, passive bool, sockOpts ...Option) (fd int, ne
}
defer func() {
// ignore EINPROGRESS for non-blocking socket connect, should be processed by caller
if t, ok := err.(*os.SyscallError); ok && t.Err == unix.EINPROGRESS {
return
}
if err != nil {
if err, ok := err.(*os.SyscallError); ok && err.Err == unix.EINPROGRESS {
return
}
_ = unix.Close(fd)
}
}()
Expand Down
6 changes: 3 additions & 3 deletions internal/socket/udp_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ func udpSocket(proto, addr string, connect bool, sockOpts ...Option) (fd int, ne
}
defer func() {
// ignore EINPROGRESS for non-blocking socket connect, should be processed by caller
if t, ok := err.(*os.SyscallError); ok && t.Err == unix.EINPROGRESS {
return
}
if err != nil {
if err, ok := err.(*os.SyscallError); ok && err.Err == unix.EINPROGRESS {
return
}
_ = unix.Close(fd)
}
}()
Expand Down
6 changes: 3 additions & 3 deletions internal/socket/unix_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ func udsSocket(proto, addr string, passive bool, sockOpts ...Option) (fd int, ne
defer func() {
// ignore EINPROGRESS for non-blocking socket connect, should be processed by caller
// though there is less situation for EINPROGRESS when using unix socket
if t, ok := err.(*os.SyscallError); ok && t.Err == unix.EINPROGRESS {
return
}
if err != nil {
if err, ok := err.(*os.SyscallError); ok && err.Err == unix.EINPROGRESS {
return
}
_ = unix.Close(fd)
}
}()
Expand Down

0 comments on commit 4331027

Please # to comment.