Skip to content

Commit

Permalink
Comment to make clear that the close order is deliberate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Scheuermann committed Nov 13, 2023
1 parent cc506bc commit 252c106
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xfr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}()
Expand Down Expand Up @@ -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)
}()
Expand Down

0 comments on commit 252c106

Please sign in to comment.