Fix: dns should put msg to cache while exchangeWithoutCache (#820)

This commit is contained in:
gVisor bot 2020-07-20 21:16:36 +08:00
parent a1accd76db
commit 4b867e11de

View file

@ -115,16 +115,14 @@ func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) {
func (r *Resolver) exchangeWithoutCache(m *D.Msg) (msg *D.Msg, err error) {
q := m.Question[0]
ret, err, shared := r.group.Do(q.String(), func() (interface{}, error) {
isIPReq := isIPRequest(q)
if isIPReq {
return r.fallbackExchange(m)
ret, err, shared := r.group.Do(q.String(), func() (result interface{}, err error) {
defer func() {
if err != nil {
return
}
msg, err := r.batchExchange(r.main, m)
if err != nil {
return nil, err
}
msg := result.(*D.Msg)
putMsgToCache(r.lruCache, q.String(), msg)
if r.mapping || r.fakeip {
ips := r.msgToIP(msg)
@ -132,7 +130,14 @@ func (r *Resolver) exchangeWithoutCache(m *D.Msg) (msg *D.Msg, err error) {
putMsgToCache(r.lruCache, ip.String(), msg)
}
}
return msg, nil
}()
isIPReq := isIPRequest(q)
if isIPReq {
return r.fallbackExchange(m)
}
return r.batchExchange(r.main, m)
})
if err == nil {