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
|
# Test Env
|
||||||
env*.sh
|
env*.sh
|
||||||
env*/
|
env*/
|
||||||
|
init.sql
|
||||||
|
|||||||
@ -12,9 +12,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]file.File, error) {
|
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
|
errC := make(chan error, 1) // collect only 1 error
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -33,17 +35,11 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
|
|||||||
|
|
||||||
// open all
|
// open all
|
||||||
cFiles, err = m.Open(openCmd)
|
cFiles, err = m.Open(openCmd)
|
||||||
if err != nil {
|
wg.Add(len(cFiles))
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait to complete
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
wg.Add(total)
|
|
||||||
|
|
||||||
// copy out
|
// copy out
|
||||||
for i, n := range c.CopyOut {
|
for i := range cFiles {
|
||||||
go func(cFile *os.File, n string) {
|
go func(cFile *os.File, n string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer cFile.Close()
|
defer cFile.Close()
|
||||||
@ -53,7 +49,7 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fc <- memfile.New(n, c)
|
fc <- memfile.New(n, c)
|
||||||
}(cFiles[i], n)
|
}(cFiles[i], c.CopyOut[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect pipe
|
// collect pipe
|
||||||
@ -79,6 +75,10 @@ func copyOutAndCollect(m *daemon.Master, c *Cmd, ptc []pipeBuff) (map[string]fil
|
|||||||
rt[name] = f
|
rt[name] = f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return rt, err
|
||||||
|
}
|
||||||
|
|
||||||
// check error
|
// check error
|
||||||
select {
|
select {
|
||||||
case err := <-errC:
|
case err := <-errC:
|
||||||
|
|||||||
@ -77,13 +77,17 @@ func (r *Runner) compile(done <-chan struct{}, task *types.CompileTask) *types.R
|
|||||||
// get compile message
|
// get compile message
|
||||||
compileMsg, err := getFile(r0.Files, msgFileName)
|
compileMsg, err := getFile(r0.Files, msgFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return compileErr("FileError" + err.Error())
|
return compileErr("FileError:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile copyout
|
// compile copyout
|
||||||
var exec []file.File
|
var exec []file.File
|
||||||
for _, n := range param.CompiledFileNames {
|
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
|
// return result
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user