Skip to content

Commit

Permalink
fix fvr client side deadlock and stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Mar 20, 2022
1 parent a1d00c9 commit a30912d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion daemon.fs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ let fvrConnect (stdin: Stream) (stdout: Stream) (verb: FVimRemoteVerb) =
stdin.Write(intbuf, 0, intbuf.Length)
stdin.Write(payload, 0, payload.Length)
stdin.Flush()
(read stdout (intbuf.AsMemory())).Wait()
// this doesn't drive the task:
// (read stdout (intbuf.AsMemory())).Wait()
// this *does* drive the task:
read stdout (intbuf.AsMemory()) |> Async.AwaitTask |> Async.StartImmediate
toInt32LE intbuf
with ex ->
trace "%O" ex
Expand Down
12 changes: 9 additions & 3 deletions model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,17 @@ let OnTerminated () =
trace "terminating nvim..."
nvim.stop 1

let mutable _detaching = false

let OnTerminating(args: CancelEventArgs) =
args.Cancel <- true
trace "window is closing"
if nvim.isRemote then Detach()
else nvim.quitall() |> ignore
if nvim.isRemote then
if not _detaching then
_detaching <- true
Detach()
else
args.Cancel <- true
nvim.quitall() |> ignore

let OnExtClosed(win: int) =
nvim.call {method = "nvim_win_close"; parameters = mkparams2 win true}
Expand Down

0 comments on commit a30912d

Please sign in to comment.