• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-sql-driver / mysql / 3601392501

pending completion
3601392501

push

github

GitHub
update changelog for Version 1.7 (#1376)

2932 of 3584 relevant lines covered (81.81%)

1490385.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/conncheck.go
1
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2
//
3
// Copyright 2019 The Go-MySQL-Driver Authors. All rights reserved.
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
// You can obtain one at http://mozilla.org/MPL/2.0/.
8

9
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
10
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
11

12
package mysql
13

14
import (
15
        "errors"
16
        "io"
17
        "net"
18
        "syscall"
19
)
20

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

23
func connCheck(conn net.Conn) error {
19,628✔
24
        var sysErr error
19,628✔
25

19,628✔
26
        sysConn, ok := conn.(syscall.Conn)
19,628✔
27
        if !ok {
19,628✔
28
                return nil
×
29
        }
×
30
        rawConn, err := sysConn.SyscallConn()
19,628✔
31
        if err != nil {
19,628✔
32
                return err
×
33
        }
×
34

35
        err = rawConn.Read(func(fd uintptr) bool {
39,256✔
36
                var buf [1]byte
19,628✔
37
                n, err := syscall.Read(int(fd), buf[:])
19,628✔
38
                switch {
19,628✔
39
                case n == 0 && err == nil:
12✔
40
                        sysErr = io.EOF
12✔
41
                case n > 0:
24✔
42
                        sysErr = errUnexpectedRead
24✔
43
                case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK:
19,568✔
44
                        sysErr = nil
19,568✔
45
                default:
24✔
46
                        sysErr = err
24✔
47
                }
48
                return true
19,628✔
49
        })
50
        if err != nil {
19,628✔
51
                return err
×
52
        }
×
53

54
        return sysErr
19,628✔
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc