Commit 0f5e7bdf authored by Vector's avatar Vector Committed by GitHub

plugin/forward: Use new msg.Id for upstream queries (#4841)

* restore 1.8.3 question revert logic; add tests (#4840)
Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
Signed-off-by: default avatarVector <815926354@qq.com>

* change origin message id
Signed-off-by: default avatarVector <815926354@qq.com>
Signed-off-by: default avatarIIvyPy <815926354@qq.com>

* Revert "restore 1.8.3 question revert logic; add tests (#4840)"

This reverts commit 95e44d91d03452556f5a8af64371fcf5f0b642d0.
Signed-off-by: default avatarIIvyPy <815926354@qq.com>
Co-authored-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent 2c575a3d
......@@ -97,6 +97,13 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
}
pc.c.SetWriteDeadline(time.Now().Add(maxTimeout))
// records the origin Id before upstream.
originId := state.Req.Id
state.Req.Id = dns.Id()
defer func(){
state.Req.Id = originId
}()
if err := pc.c.WriteMsg(state.Req); err != nil {
pc.c.Close() // not giving it back
if err == io.EOF && cached {
......@@ -114,6 +121,10 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
if err == io.EOF && cached {
return nil, ErrCachedClosed
}
// recovery the origin Id after upstream.
if ret != nil{
ret.Id = originId
}
return ret, err
}
// drop out-of-order responses
......@@ -121,6 +132,8 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
break
}
}
// recovery the origin Id after upstream.
ret.Id = originId
p.transport.Yield(pc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment