dont use sigData, as this will allocate a structur

Just send the plain radix node. This decreases the amount of
allocations
This commit is contained in:
Miek Gieben 2012-09-13 10:54:38 +02:00
parent ddd31e3fb8
commit 001f4b6d61
1 changed files with 9 additions and 9 deletions

18
zone.go
View File

@ -323,13 +323,13 @@ func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) err
} }
errChan := make(chan error) errChan := make(chan error)
signChan := make(chan *signData, config.SignerRoutines*2) radChan := make(chan *radix.Radix, config.SignerRoutines*2)
// Start the signer goroutines // Start the signer goroutines
wg := new(sync.WaitGroup) wg := new(sync.WaitGroup)
wg.Add(config.SignerRoutines) wg.Add(config.SignerRoutines)
for i := 0; i < config.SignerRoutines; i++ { for i := 0; i < config.SignerRoutines; i++ {
go signerRoutine(wg, keys, keytags, config, signChan, errChan) go signerRoutine(wg, keys, keytags, config, radChan, errChan)
} }
apex, e := z.Radix.Find(toRadixName(z.Origin)) apex, e := z.Radix.Find(toRadixName(z.Origin))
@ -338,7 +338,7 @@ func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) err
} }
config.minttl = apex.Value.(*ZoneData).RR[TypeSOA][0].(*RR_SOA).Minttl config.minttl = apex.Value.(*ZoneData).RR[TypeSOA][0].(*RR_SOA).Minttl
next := apex.Next() next := apex.Next()
signChan <- &signData{apex.Value.(*ZoneData), next.Value.(*ZoneData)} radChan <- apex
var err error var err error
Sign: Sign:
@ -348,11 +348,11 @@ Sign:
break Sign break Sign
default: default:
nextnext := next.Next() nextnext := next.Next()
signChan <- &signData{next.Value.(*ZoneData), nextnext.Value.(*ZoneData)} radChan <- next
next = nextnext next = nextnext
} }
} }
close(signChan) close(radChan)
close(errChan) close(errChan)
if err != nil { if err != nil {
return err return err
@ -361,8 +361,8 @@ Sign:
return nil return nil
} }
// signerRoutine is a small helper routines to make the concurrent signing work. // signerRoutine is a small helper routine to make the concurrent signing work.
func signerRoutine(wg *sync.WaitGroup, keys map[*RR_DNSKEY]PrivateKey, keytags map[*RR_DNSKEY]uint16, config *SignatureConfig, in chan *signData, err chan error) { func signerRoutine(wg *sync.WaitGroup, keys map[*RR_DNSKEY]PrivateKey, keytags map[*RR_DNSKEY]uint16, config *SignatureConfig, in chan *radix.Radix, err chan error) {
defer wg.Done() defer wg.Done()
for { for {
select { select {
@ -370,8 +370,8 @@ func signerRoutine(wg *sync.WaitGroup, keys map[*RR_DNSKEY]PrivateKey, keytags m
if !ok { if !ok {
return return
} }
log.Printf("Signing node %s\n", data.node.Name) log.Printf("Signing node %s\n", data.Value.(*ZoneData).Name)
e := data.node.Sign(data.next, keys, keytags, config) e := data.Value.(*ZoneData).Sign(data.Next().Value.(*ZoneData), keys, keytags, config)
if e != nil { if e != nil {
err <- e err <- e
return return