mirror of
https://github.com/jackc/pgx.git
synced 2025-05-31 11:42:24 +00:00
writeAll dies on permanent net errors
This commit is contained in:
parent
5b9108a20c
commit
e3d431d0df
@ -398,11 +398,15 @@ func (pgConn *PgConn) hardClose() error {
|
|||||||
return pgConn.conn.Close()
|
return pgConn.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeAll writes the entire buffer successfully or it hard closes the connection.
|
// writeAll writes the entire buffer. The connection is hard closed on a partial write or a non-temporary error.
|
||||||
func (pgConn *PgConn) writeAll(buf []byte) error {
|
func (pgConn *PgConn) writeAll(buf []byte) error {
|
||||||
n, err := pgConn.conn.Write(buf)
|
n, err := pgConn.conn.Write(buf)
|
||||||
if err != nil && n > 0 {
|
if err != nil {
|
||||||
pgConn.hardClose()
|
if n > 0 {
|
||||||
|
pgConn.hardClose()
|
||||||
|
} else if ne, ok := err.(net.Error); ok && !ne.Temporary() {
|
||||||
|
pgConn.hardClose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user