From cf7b89d3c4cc7f8c33e20b37eaeae3d0f450141e Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Tue, 3 Sep 2024 12:24:03 +0100 Subject: [PATCH] Issue #145. --- conn.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/conn.go b/conn.go index ded28b3..665ec2e 100644 --- a/conn.go +++ b/conn.go @@ -389,11 +389,20 @@ func timeoutCallback(ctx context.Context, mod api.Module, pDB uint32, count, tmo } if delay = min(delay, tmout-prior); delay > 0 { - time.Sleep(time.Duration(delay) * time.Millisecond) - retry = 1 + delay := time.Duration(delay) * time.Millisecond + if c.interrupt == nil || c.interrupt.Done() == nil { + time.Sleep(delay) + return 1 + } + select { + case <-c.interrupt.Done(): + // + case <-time.After(delay): + return 1 + } } } - return retry + return 0 } // BusyHandler registers a callback to handle [BUSY] errors.