mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
Remove context.Context from request.Request (#2726)
* Remove context.Context from request.Request This removes the context from request.Request and makes all the changes in the code to make it compile again. It's all mechanical. It did unearth some weirdness in that the context was kept in handler structs which may cause havoc with concurrently handling of requests. Fixes #2721 Signed-off-by: Miek Gieben <miek@miek.nl> * Make test compile Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package upstream
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -18,8 +19,8 @@ type Upstream struct{}
|
||||
func New() *Upstream { return &Upstream{} }
|
||||
|
||||
// Lookup routes lookups to our selves or forward to a remote.
|
||||
func (u *Upstream) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) {
|
||||
server, ok := state.Context.Value(dnsserver.Key{}).(*dnsserver.Server)
|
||||
func (u *Upstream) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error) {
|
||||
server, ok := ctx.Value(dnsserver.Key{}).(*dnsserver.Server)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("no full server is running")
|
||||
}
|
||||
@@ -29,7 +30,7 @@ func (u *Upstream) Lookup(state request.Request, name string, typ uint16) (*dns.
|
||||
|
||||
nw := nonwriter.New(state.W)
|
||||
|
||||
server.ServeDNS(state.Context, nw, req)
|
||||
server.ServeDNS(ctx, nw, req)
|
||||
|
||||
return nw.Msg, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user