Skip to content

Commit

Permalink
Move pid to init() and update connattrs handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden committed Jun 21, 2015
1 parent 97d1741 commit be9a3ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"database/sql"
"database/sql/driver"
"net"
"os"
"strconv"
)

// This struct is exported to make the driver directly accessible.
Expand All @@ -30,6 +32,8 @@ type MySQLDriver struct{}
// Custom dial functions must be registered with RegisterDial
type DialFunc func(addr string) (net.Conn, error)

var pid string

var dials map[string]DialFunc

// RegisterDial registers a custom dial function. It can then be used by the
Expand Down Expand Up @@ -145,5 +149,6 @@ func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
}

func init() {
pid = strconv.Itoa(os.Getpid())
sql.Register("mysql", &MySQLDriver{})
}
16 changes: 8 additions & 8 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import (
"fmt"
"io"
"math"
"os"
"os"
"path"
"runtime"
"strconv"
"time"
)

Expand Down Expand Up @@ -238,12 +237,13 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
// User Password
scrambleBuff := scramblePassword(cipher, []byte(mc.cfg.passwd))

attrs := make(map[string]string)
attrs["_os"] = runtime.GOOS
attrs["_client_name"] = "Go MySQL Driver"
attrs["_pid"] = strconv.Itoa(os.Getpid())
attrs["_platform"] = runtime.GOARCH
attrs["program_name"] = path.Base(os.Args[0])
attrs := map[string]string {
"_os": runtime.GOOS,
"_client_name": "Go-MySQL-Driver",
"_pid": pid,
"_platform": runtime.GOARCH,
"program_name": path.Base(os.Args[0]),
}

attrlen := 0
for attrname, attrvalue := range attrs {
Expand Down

0 comments on commit be9a3ec

Please sign in to comment.