fix: deadlock in lua job add function and not taking proper amount of args

extended-job-api
TorchedSammy 2022-05-17 18:00:28 -04:00
parent b5c78a39a8
commit 9f6a07c90a
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 2 additions and 5 deletions

7
job.go
View File

@ -179,7 +179,7 @@ func (j *jobHandler) loader(rtm *rt.Runtime) *rt.Table {
jobFuncs := map[string]util.LuaExport{ jobFuncs := map[string]util.LuaExport{
"all": {j.luaAllJobs, 0, false}, "all": {j.luaAllJobs, 0, false},
"get": {j.luaGetJob, 1, false}, "get": {j.luaGetJob, 1, false},
"add": {j.luaAddJob, 1, false}, "add": {j.luaAddJob, 2, false},
} }
luaJob := rt.NewTable() luaJob := rt.NewTable()
@ -209,10 +209,7 @@ func (j *jobHandler) luaGetJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
} }
func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
j.mu.RLock() if err := c.CheckNArgs(2); err != nil {
defer j.mu.RUnlock()
if err := c.Check1Arg(); err != nil {
return nil, err return nil, err
} }
cmd, err := c.StringArg(0) cmd, err := c.StringArg(0)