1
0
Fork 0
forked from forgejo/forgejo

Update to latest mssqldriver (#7613)

* New driver does not tolerate USE - handle this by closing db and reopening db in the new dbname
This commit is contained in:
zeripath 2019-07-26 05:10:20 +01:00 committed by GitHub
parent bebc6a3c77
commit 78e5317242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 2376 additions and 598 deletions

View file

@ -14,7 +14,7 @@ type timeoutConn struct {
continueRead bool
}
func NewTimeoutConn(conn net.Conn, timeout time.Duration) *timeoutConn {
func newTimeoutConn(conn net.Conn, timeout time.Duration) *timeoutConn {
return &timeoutConn{
c: conn,
timeout: timeout,
@ -48,9 +48,11 @@ func (c *timeoutConn) Read(b []byte) (n int, err error) {
n, err = c.buf.Read(b)
return
}
err = c.c.SetDeadline(time.Now().Add(c.timeout))
if err != nil {
return
if c.timeout > 0 {
err = c.c.SetDeadline(time.Now().Add(c.timeout))
if err != nil {
return
}
}
return c.c.Read(b)
}
@ -58,7 +60,7 @@ func (c *timeoutConn) Read(b []byte) (n int, err error) {
func (c *timeoutConn) Write(b []byte) (n int, err error) {
if c.buf != nil {
if !c.packetPending {
c.buf.BeginPacket(packPrelogin)
c.buf.BeginPacket(packPrelogin, false)
c.packetPending = true
}
n, err = c.buf.Write(b)
@ -67,9 +69,11 @@ func (c *timeoutConn) Write(b []byte) (n int, err error) {
}
return
}
err = c.c.SetDeadline(time.Now().Add(c.timeout))
if err != nil {
return
if c.timeout > 0 {
err = c.c.SetDeadline(time.Now().Add(c.timeout))
if err != nil {
return
}
}
return c.c.Write(b)
}