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

go-sql-driver / mysql / 14570841909

21 Apr 2025 09:10AM UTC coverage: 83.0% (-0.01%) from 83.01%
14570841909

Pull #1692

github

web-flow
Merge branch 'master' into clientDeprecateEOF
Pull Request #1692: MariaDB metadata skipping

170 of 203 new or added lines in 6 files covered. (83.74%)

3 existing lines in 1 file now uncovered.

3320 of 4000 relevant lines covered (83.0%)

2184086.06 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 {
20,616✔
24
        var sysErr error
20,616✔
25

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

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

54
        return sysErr
20,616✔
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