mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
save compiled message
This commit is contained in:
parent
b0345501e3
commit
5763978012
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@
|
||||
# Test Env
|
||||
env*.sh
|
||||
env*/
|
||||
init.sql
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user