From dfc49cbc10207da6e7c7eb813293c30ba6bf8eb9 Mon Sep 17 00:00:00 2001 From: Simon Cousineau Date: Wed, 7 Feb 2024 17:36:42 +0000 Subject: [PATCH] Create ticker outside critical section --- conn.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conn.go b/conn.go index 6fe40c8..6ca2b68 100644 --- a/conn.go +++ b/conn.go @@ -166,10 +166,8 @@ func (c *Conn) Query(ctx context.Context, name string) (dnsmessage.ResourceHeade query := &query{nameWithSuffix, queryChan} c.mu.Lock() c.queries = append(c.queries, query) - ticker := time.NewTicker(c.queryInterval) c.mu.Unlock() - defer ticker.Stop() defer func() { c.mu.Lock() defer c.mu.Unlock() @@ -180,6 +178,9 @@ func (c *Conn) Query(ctx context.Context, name string) (dnsmessage.ResourceHeade } }() + ticker := time.NewTicker(c.queryInterval) + defer ticker.Stop() + c.sendQuestion(nameWithSuffix) for { select {