8000024 introduced a race condition in forwardMessage:
msgChan := make(chan *dns.Msg, 2)
go exchangeMessages(cloudFlareConn, q, msgChan)
go exchangeMessages(googleConn, q, msgChan)
m = <-msgChan
if m != nil {
return m
}
return <-msgChan
This code makes the function return as soon as one exchangeMessage is done, but the other is still running and has a reference to its connection.
The deferred func then puts back both connections in the pool, while one is still in use and could be picked up by another requester and corrupt the messages.
exchangeMessages should be the one in charge of handling the pools.
8000024 introduced a race condition in forwardMessage:
This code makes the function return as soon as one exchangeMessage is done, but the other is still running and has a reference to its connection.
The deferred
func
then puts back both connections in the pool, while one is still in use and could be picked up by another requester and corrupt the messages.exchangeMessages should be the one in charge of handling the pools.
I can write something to address this issue.