Skip to content

Commit ab4d1ac

Browse files
author
James Cor
committed
cleanup
1 parent 877067d commit ab4d1ac

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

server/handler.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
660660
resetCallback := callback
661661
if c.StatusFlags&uint16(mysql.ServerCursorExists) != 0 {
662662
resetCallback = func(r *sqltypes.Result, more bool) error {
663-
buf.Reset()
663+
defer buf.Reset()
664664
return callback(r, more)
665665
}
666666
}
@@ -685,8 +685,8 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
685685
if iErr == io.EOF {
686686
return nil
687687
}
688-
if err != nil {
689-
return err
688+
if iErr != nil {
689+
return iErr
690690
}
691691
select {
692692
case rowChan <- row:
@@ -756,14 +756,7 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
756756
}
757757
}
758758

759-
// timer has gone off
760-
if !timer.Reset(waitTime) {
761-
if h.readTimeout != 0 {
762-
// Cancel and return so Vitess can call the CloseConnection callback
763-
ctx.GetLogger().Tracef("connection timeout")
764-
return ErrRowTimeout.New()
765-
}
766-
}
759+
timer.Reset(waitTime)
767760
}
768761
})
769762

@@ -847,7 +840,7 @@ func (h *Handler) resultForValueRowIter(ctx *sql.Context, c *mysql.Conn, schema
847840
resetCallback := callback
848841
if c.StatusFlags&uint16(mysql.ServerCursorExists) != 0 {
849842
resetCallback = func(r *sqltypes.Result, more bool) error {
850-
buf.Reset()
843+
defer buf.Reset()
851844
return callback(r, more)
852845
}
853846
}
@@ -933,14 +926,7 @@ func (h *Handler) resultForValueRowIter(ctx *sql.Context, c *mysql.Conn, schema
933926
}
934927
}
935928

936-
// timer has gone off
937-
if !timer.Reset(waitTime) {
938-
if h.readTimeout != 0 {
939-
// Cancel and return so Vitess can call the CloseConnection callback
940-
ctx.GetLogger().Tracef("connection timeout")
941-
return ErrRowTimeout.New()
942-
}
943-
}
929+
timer.Reset(waitTime)
944930
}
945931
})
946932

0 commit comments

Comments
 (0)