Extend handling of unexpected EOF to the backend
In the original issue [1] and commit [2], support for unexpected EOF was added to the frontend to detect when a connection was closed abruptly. Additionally, this allows us to differentiate normal io.EOF errors with unexpected errors in the backend. [1] https://github.com/jackc/pgx/issues/662/ [2] https://github.com/jackc/pgproto3/commit/595780be0f9f581451a23a5151b77f782202ad72
This commit is contained in:
+3
-3
@@ -58,7 +58,7 @@ func (b *Backend) ReceiveStartupMessage() (FrontendMessage, error) {
|
||||
|
||||
buf, err = b.cr.Next(msgSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, translateEOFtoErrUnexpectedEOF(err)
|
||||
}
|
||||
|
||||
code := binary.BigEndian.Uint32(buf)
|
||||
@@ -98,7 +98,7 @@ func (b *Backend) Receive() (FrontendMessage, error) {
|
||||
if !b.partialMsg {
|
||||
header, err := b.cr.Next(5)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, translateEOFtoErrUnexpectedEOF(err)
|
||||
}
|
||||
|
||||
b.msgType = header[0]
|
||||
@@ -152,7 +152,7 @@ func (b *Backend) Receive() (FrontendMessage, error) {
|
||||
|
||||
msgBody, err := b.cr.Next(b.bodyLen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, translateEOFtoErrUnexpectedEOF(err)
|
||||
}
|
||||
|
||||
b.partialMsg = false
|
||||
|
||||
Reference in New Issue
Block a user