From 252c106d00d1eb918514e51af3c10c230dfd879b Mon Sep 17 00:00:00 2001 From: Tim Scheuermann Date: Mon, 13 Nov 2023 15:22:03 +0100 Subject: [PATCH] Comment to make clear that the close order is deliberate --- xfr.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xfr.go b/xfr.go index 63608b2de..05b3c5add 100644 --- a/xfr.go +++ b/xfr.go @@ -81,6 +81,9 @@ func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) { func (t *Transfer) inAxfr(q *Msg, c chan *Envelope) { first := true defer func() { + // First close the connection, then the channel. This allows functions blocked on + // the channel to assume that the connection is closed and no further operations are + // pending when they resume. t.Close() close(c) }() @@ -134,6 +137,9 @@ func (t *Transfer) inIxfr(q *Msg, c chan *Envelope) { n := 0 qser := q.Ns[0].(*SOA).Serial defer func() { + // First close the connection, then the channel. This allows functions blocked on + // the channel to assume that the connection is closed and no further operations are + // pending when they resume. t.Close() close(c) }()