only count packages sent to building for batch-limit

This commit is contained in:
2021-12-02 10:08:51 +01:00
parent d65cab3303
commit bafb7a3b83
2 changed files with 17 additions and 6 deletions

21
main.go
View File

@@ -358,6 +358,16 @@ func (b *BuildManager) parseWorker() {
}
b.parseWG.Done()
b.queuedLock.RLock()
if b.queued[pkg.March] >= conf.Build.Batch {
b.queuedLock.RUnlock()
continue
}
b.queuedLock.Lock()
b.queued[pkg.March]++
b.queuedLock.Unlock()
b.build[pkg.March] <- pkg
}
}
@@ -645,10 +655,14 @@ func (b *BuildManager) syncWorker() {
check(err)
b.alpmMutex.Unlock()
// clear batch limits
b.queuedLock.Lock()
b.queued = map[string]int{}
b.queuedLock.Unlock()
pkgBuilds, err := Glob(filepath.Join(conf.Basedir.Upstream, "/**/PKGBUILD"))
check(err)
queued := map[string]int{}
for _, pkgbuild := range pkgBuilds {
if b.exit {
return
@@ -687,11 +701,6 @@ func (b *BuildManager) syncWorker() {
continue
}
if queued[march] >= conf.Build.Batch {
continue
}
queued[march]++
// send to parse
b.parseWG.Add(1)
b.parse <- &BuildPackage{

View File

@@ -67,6 +67,8 @@ type BuildManager struct {
buildProcesses []*os.Process
buildProcMutex sync.RWMutex
alpmMutex sync.RWMutex
queued map[string]int
queuedLock sync.RWMutex
}
type Conf struct {