fix merge

This commit is contained in:
Miek Gieben 2012-08-28 10:53:19 +02:00
commit 9ce7de998f
1 changed files with 19 additions and 11 deletions

30
xfr.go
View File

@ -2,8 +2,8 @@ package dns
// XfrToken is used when doing [IA]xfr with a remote server.
type XfrToken struct {
RR []RR // the set of RRs in the answer section form the message of the server
Error error // if something went wrong, this contains the error
RR []RR // the set of RRs in the answer section form the message of the server
Error error // if something went wrong, this contains the error
}
// XfrReceive performs a [AI]xfr request (depends on the message's Qtype). It returns
@ -146,20 +146,26 @@ func checkXfrSOA(in *Msg, first bool) bool {
// the channel c.
// long as the channel c is open ... TODO(mg): docs
// tsig is done, enveloping is done, voor de rest niks... TODO
func XfrSend(w ResponseWriter, req *Msg, c chan *XfrToken) error {
switch req.Question[0].Qtype {
// XfrSend performs an outgoing [IX]xfr depending on the request message. As
// long as the channel c is open the transfer proceeds. Any errors when
// sending the messages to the client are signaled in the error
// pointer.
// TSIG and enveloping is handled by this function.
func XfrSend(w ResponseWriter, q *Msg, c chan *XfrToken, e *error) error {
switch q.Question[0].Qtype {
case TypeAXFR, TypeIXFR:
go axfrSend(w, req, c)
go axfrSend(w, q, c, e)
return nil
default:
return ErrXfrType
}
return nil
panic("not reached")
}
// TODO(mg): count the RRs and the resulting size.
func axfrSend(w ResponseWriter, req *Msg, c chan *XfrToken) {
// when to stop
func axfrSend(w ResponseWriter, req *Msg, c chan *XfrToken, e *error) {
rep := new(Msg)
rep.SetReply(req)
rep.MsgHdr.Authoritative = true
@ -169,7 +175,10 @@ func axfrSend(w ResponseWriter, req *Msg, c chan *XfrToken) {
for x := range c {
// assume it fits
rep.Answer = append(rep.Answer, x.RR...)
w.Write(rep)
if err := w.Write(rep); e != nil {
*e = err
return
}
if first {
first = !first
w.TsigTimersOnly(first)
@ -177,4 +186,3 @@ func axfrSend(w ResponseWriter, req *Msg, c chan *XfrToken) {
rep.Answer = nil
}
}