Reduce allocs.

This commit is contained in:
Nuno Cruces
2024-09-03 17:31:30 +01:00
parent cf7b89d3c4
commit b51234cc82

10
conn.go
View File

@@ -23,6 +23,7 @@ type Conn struct {
interrupt context.Context
pending *Stmt
stmts []*Stmt
timer *time.Timer
busy func(int) bool
log func(xErrorCode, string)
collation func(*Conn, string)
@@ -394,10 +395,15 @@ func timeoutCallback(ctx context.Context, mod api.Module, pDB uint32, count, tmo
time.Sleep(delay)
return 1
}
if c.timer == nil {
c.timer = time.NewTimer(delay)
} else {
c.timer.Reset(delay)
}
select {
case <-c.interrupt.Done():
//
case <-time.After(delay):
c.timer.Stop()
case <-c.timer.C:
return 1
}
}