Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
Signed-off-by: YarBor <[email protected]>
  • Loading branch information
YarBor committed May 17, 2024
1 parent 5bb551d commit c9328e1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cluster/router/script/instance/js_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,20 @@ func (i *jsInstances) Compile(key, rawScript string) error {
return nil
} else {

newPg, err := goja.Compile(key+`_jsScriptRoute`, jsScriptPrefix+rawScript, true)
if err != nil {
return err
}

i.pgLock.Lock()
defer i.pgLock.Unlock()
// double check to avoid race
if pg, ok = i.program[rawScript]; ok {
pg.addCount(1)
} else {
newPg, err := goja.Compile(key+`_jsScriptRoute`, jsScriptPrefix+rawScript, true)
if err != nil {
return err
}
i.program[rawScript] = newProgram(newPg)
}
i.pgLock.Unlock()
return nil
}

}

func (i *jsInstances) Destroy(_, rawScript string) {
Expand Down

0 comments on commit c9328e1

Please sign in to comment.