Skip to content

Commit

Permalink
Fix method scope, private -> public. (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongzl authored Apr 14, 2022
1 parent 4cdd113 commit fe2430d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 5 additions & 7 deletions net/conncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.


package gxnet

import (
Expand All @@ -38,7 +37,7 @@ import (

var errUnexpectedRead = errors.New("unexpected read from socket")

func connCheck(conn net.Conn) error {
func ConnCheck(conn net.Conn) error {
var sysErr error

sysConn, ok := conn.(syscall.Conn)
Expand All @@ -52,16 +51,16 @@ func connCheck(conn net.Conn) error {

err = rawConn.Read(func(fd uintptr) bool {
var buf [1]byte
n, err := syscall.Read(int(fd), buf[:])
n, readErr := syscall.Read(int(fd), buf[:])
switch {
case n == 0 && err == nil:
case n == 0 && readErr == nil:
sysErr = io.EOF
case n > 0:
sysErr = errUnexpectedRead
case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK:
case readErr == syscall.EAGAIN || readErr == syscall.EWOULDBLOCK:
sysErr = nil
default:
sysErr = err
sysErr = readErr
}
return true
})
Expand All @@ -71,4 +70,3 @@ func connCheck(conn net.Conn) error {

return sysErr
}

3 changes: 1 addition & 2 deletions net/conncheck_dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.


package gxnet

import (
"net"
)

func connCheck(conn net.Conn) error {
func ConnCheck(conn net.Conn) error {
return nil
}

0 comments on commit fe2430d

Please sign in to comment.