save compiled message

This commit is contained in:
criyle 2020-01-10 00:57:33 -05:00
parent b0345501e3
commit 5763978012
3 changed files with 18 additions and 13 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@
# Test Env
env*.sh
env*/
init.sql

View File

@ -12,9 +12,11 @@ import (
)
func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]file.File, error) {
total := len(c.CopyOut) + len(ptc)
// wait to complete
var wg sync.WaitGroup
wg.Add(len(ptc))
fc := make(chan file.File, total)
fc := make(chan file.File, len(ptc)+len(c.CopyOut))
errC := make(chan error, 1) // collect only 1 error
var (
@ -33,17 +35,11 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
// open all
cFiles, err = m.Open(openCmd)
if err != nil {
return nil, err
wg.Add(len(cFiles))
}
}
// wait to complete
var wg sync.WaitGroup
wg.Add(total)
// copy out
for i, n := range c.CopyOut {
for i := range cFiles {
go func(cFile *os.File, n string) {
defer wg.Done()
defer cFile.Close()
@ -53,7 +49,7 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
return
}
fc <- memfile.New(n, c)
}(cFiles[i], n)
}(cFiles[i], c.CopyOut[i])
}
// collect pipe
@ -79,6 +75,10 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
rt[name] = f
}
if err != nil {
return rt, err
}
// check error
select {
case err := <-errC:

View File

@ -77,13 +77,17 @@ func (r *Runner) compile(done <-chan struct{}, task *types.CompileTask) *types.R
// get compile message
compileMsg, err := getFile(r0.Files, msgFileName)
if err != nil {
return compileErr("FileError" + err.Error())
return compileErr("FileError:" + err.Error())
}
// compile copyout
var exec []file.File
for _, n := range param.CompiledFileNames {
exec = append(exec, r0.Files[n])
f, err := getFile(r0.Files, n)
if err != nil {
return compileErr("FileError:" + err.Error())
}
exec = append(exec, memfile.New(n, f))
}
// return result