Skip to content

Commit

Permalink
syscall: release a js.Func object in fsCall
Browse files Browse the repository at this point in the history
A js.Func object in fsCall was created for each call but never
released. This CL fixes this.

Change-Id: I2e2b504cbf4fb130b8cfe890a66d3a66aadf56a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/217417
Run-TryBot: Hajime Hoshi <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Agniva De Sarker <[email protected]>
Reviewed-by: Richard Musiol <[email protected]>
  • Loading branch information
hajimehoshi committed Feb 2, 2020
1 parent 866920a commit 753d56d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/syscall/fs_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {
}

c := make(chan callResult, 1)
jsFS.Call(name, append(args, js.FuncOf(func(this js.Value, args []js.Value) interface{} {
f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
var res callResult

if len(args) >= 1 { // on Node.js 8, fs.utimes calls the callback without any arguments
Expand All @@ -511,7 +511,9 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {

c <- res
return nil
}))...)
})
defer f.Release()
jsFS.Call(name, append(args, f)...)
res := <-c
return res.val, res.err
}
Expand Down

0 comments on commit 753d56d

Please sign in to comment.