Use the better name: SingleInflight
This commit is contained in:
parent
0adc9a3afe
commit
2b6e9122bd
14
client.go
14
client.go
|
@ -31,16 +31,16 @@ type reply struct {
|
|||
// A Client defines parameter for a DNS client. A nil
|
||||
// Client is usable for sending queries.
|
||||
type Client struct {
|
||||
Net string // if "tcp" a TCP query will be initiated, otherwise an UDP one (default is "" for UDP)
|
||||
ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections (ns), defaults to 2 * 1e9
|
||||
WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections (ns), defaults to 2 * 1e9
|
||||
TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret>, zonename must be fully qualified
|
||||
Inflight bool // if true suppress multiple outstanding queries for the same Qname, Qtype and Qclass
|
||||
group singleflight
|
||||
Net string // if "tcp" a TCP query will be initiated, otherwise an UDP one (default is "" for UDP)
|
||||
ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections (ns), defaults to 2 * 1e9
|
||||
WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections (ns), defaults to 2 * 1e9
|
||||
TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret>, zonename must be fully qualified
|
||||
SingleInflight bool // if true suppress multiple outstanding queries for the same Qname, Qtype and Qclass
|
||||
group singleflight
|
||||
}
|
||||
|
||||
func (c *Client) exchangeMerge(m *Msg, a string, s net.Conn) (r *Msg, rtt time.Duration, err error) {
|
||||
if !c.Inflight {
|
||||
if !c.SingleInflight {
|
||||
if s == nil {
|
||||
return c.exchange(m, a)
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ func TestClientEDNS0(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestInflight(t *testing.T) {
|
||||
func TestSingleSingleInflight(t *testing.T) {
|
||||
m := new(Msg)
|
||||
m.SetQuestion("miek.nl.", TypeDNSKEY)
|
||||
|
||||
c := new(Client)
|
||||
c.Inflight = true
|
||||
c.SingleInflight = true
|
||||
nr := 10
|
||||
ch := make(chan time.Duration)
|
||||
for i := 0; i < nr; i++ {
|
||||
|
|
2
dns.go
2
dns.go
|
@ -64,7 +64,7 @@
|
|||
// For asynchronous queries it is easy to wrap Exchange() in a goroutine. Suppressing
|
||||
// multiple outstanding queries (with the same question, type and class) is as easy as setting:
|
||||
//
|
||||
// c.Inflight = true
|
||||
// c.SingleInflight = true
|
||||
//
|
||||
// A dns message consists out of four sections.
|
||||
// The question section: in.Question, the answer section: in.Answer,
|
||||
|
|
|
@ -174,7 +174,7 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
|
|||
for {
|
||||
l := len(q[off:])
|
||||
for i := 0; i < l; i++ {
|
||||
b[i] = q[off+i] | ( 'a' - 'A')
|
||||
b[i] = q[off+i] | ('a' - 'A')
|
||||
}
|
||||
if h, ok := mux.z[string(b[:l])]; ok { // 'causes garbage, might want to change the map key
|
||||
if t != TypeDS {
|
||||
|
|
Loading…
Reference in New Issue