Fix (r *msgReader) rxMsg() error guard clause

rxMsg() has a guard clause that checks if the msgReader has already
encountered an error. It should return that pre-existing error. It
was incorrectly returning a local `err` variable instead of `r.err`.
experiment
Jack Christensen 2016-01-29 16:23:43 -06:00
parent 9f9a9779ac
commit beed0c0e5f
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# Tip
* Fix msgReader.rxMsg bug when msgReader already has error
* Add support for database/sql.Scanner and database/sql/driver.Valuer interfaces
* Go float64 can no longer be encoded to a PostgreSQL float4
* Add ConnPool.Reset method

View File

@ -32,9 +32,9 @@ func (r *msgReader) fatal(err error) {
}
// rxMsg reads the type and size of the next message.
func (r *msgReader) rxMsg() (t byte, err error) {
func (r *msgReader) rxMsg() (byte, error) {
if r.err != nil {
return 0, err
return 0, r.err
}
if r.msgBytesRemaining > 0 {
@ -46,7 +46,7 @@ func (r *msgReader) rxMsg() (t byte, err error) {
}
b := r.buf[0:5]
_, err = io.ReadFull(r.reader, b)
_, err := io.ReadFull(r.reader, b)
r.msgBytesRemaining = int32(binary.BigEndian.Uint32(b[1:])) - 4
return b[0], err
}