mirror of https://github.com/jackc/pgx.git
Partially migrate to writeBuf
parent
b25aea5c52
commit
9ab8fb4877
23
conn.go
23
conn.go
|
@ -243,7 +243,11 @@ func (c *Conn) Close() (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.txMsg('X', c.getBuf())
|
wbuf := newWriteBuf(c.wbuf[0:0], 'X')
|
||||||
|
wbuf.closeMsg()
|
||||||
|
|
||||||
|
_, err = c.conn.Write(wbuf.buf)
|
||||||
|
|
||||||
c.die(errors.New("Closed"))
|
c.die(errors.New("Closed"))
|
||||||
c.logger.Info("Closed connection")
|
c.logger.Info("Closed connection")
|
||||||
return err
|
return err
|
||||||
|
@ -1190,18 +1194,13 @@ func (c *Conn) txMsg(identifier byte, buf *bytes.Buffer) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) txPasswordMessage(password string) (err error) {
|
func (c *Conn) txPasswordMessage(password string) (err error) {
|
||||||
buf := c.getBuf()
|
wbuf := newWriteBuf(c.wbuf[0:0], 'p')
|
||||||
|
wbuf.WriteCString(password)
|
||||||
|
wbuf.closeMsg()
|
||||||
|
|
||||||
_, err = buf.WriteString(password)
|
_, err = c.conn.Write(wbuf.buf)
|
||||||
if err != nil {
|
|
||||||
return
|
return err
|
||||||
}
|
|
||||||
buf.WriteByte(0)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = c.txMsg('p', buf)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the shared connection buffer. Since bytes.Buffer never releases memory from
|
// Gets the shared connection buffer. Since bytes.Buffer never releases memory from
|
||||||
|
|
Loading…
Reference in New Issue