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
|
// A Client defines parameter for a DNS client. A nil
|
||||||
// Client is usable for sending queries.
|
// Client is usable for sending queries.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Net string // if "tcp" a TCP query will be initiated, otherwise an UDP one (default is "" for UDP)
|
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
|
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
|
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
|
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
|
SingleInflight bool // if true suppress multiple outstanding queries for the same Qname, Qtype and Qclass
|
||||||
group singleflight
|
group singleflight
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) exchangeMerge(m *Msg, a string, s net.Conn) (r *Msg, rtt time.Duration, err error) {
|
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 {
|
if s == nil {
|
||||||
return c.exchange(m, a)
|
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 := new(Msg)
|
||||||
m.SetQuestion("miek.nl.", TypeDNSKEY)
|
m.SetQuestion("miek.nl.", TypeDNSKEY)
|
||||||
|
|
||||||
c := new(Client)
|
c := new(Client)
|
||||||
c.Inflight = true
|
c.SingleInflight = true
|
||||||
nr := 10
|
nr := 10
|
||||||
ch := make(chan time.Duration)
|
ch := make(chan time.Duration)
|
||||||
for i := 0; i < nr; i++ {
|
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
|
// 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:
|
// 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.
|
// A dns message consists out of four sections.
|
||||||
// The question section: in.Question, the answer section: in.Answer,
|
// The question section: in.Question, the answer section: in.Answer,
|
||||||
|
|
|
@ -174,7 +174,7 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
|
||||||
for {
|
for {
|
||||||
l := len(q[off:])
|
l := len(q[off:])
|
||||||
for i := 0; i < l; i++ {
|
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 h, ok := mux.z[string(b[:l])]; ok { // 'causes garbage, might want to change the map key
|
||||||
if t != TypeDS {
|
if t != TypeDS {
|
||||||
|
|
2
xfr.go
2
xfr.go
|
@ -70,7 +70,7 @@ func (w *reply) axfrIn(q *Msg, c chan *Envelope) {
|
||||||
}
|
}
|
||||||
first = !first
|
first = !first
|
||||||
// only one answer that is SOA, receive more
|
// only one answer that is SOA, receive more
|
||||||
if (len(in.Answer) == 1) {
|
if len(in.Answer) == 1 {
|
||||||
w.tsigTimersOnly = true
|
w.tsigTimersOnly = true
|
||||||
c <- &Envelope{in.Answer, nil}
|
c <- &Envelope{in.Answer, nil}
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue