Skip to content

Commit a30912d

Browse files
author
Yatao Li
committed
fix fvr client side deadlock and stack overflow
1 parent a1d00c9 commit a30912d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

daemon.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ let fvrConnect (stdin: Stream) (stdout: Stream) (verb: FVimRemoteVerb) =
190190
stdin.Write(intbuf, 0, intbuf.Length)
191191
stdin.Write(payload, 0, payload.Length)
192192
stdin.Flush()
193-
(read stdout (intbuf.AsMemory())).Wait()
193+
// this doesn't drive the task:
194+
// (read stdout (intbuf.AsMemory())).Wait()
195+
// this *does* drive the task:
196+
read stdout (intbuf.AsMemory()) |> Async.AwaitTask |> Async.StartImmediate
194197
toInt32LE intbuf
195198
with ex ->
196199
trace "%O" ex

model.fs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,17 @@ let OnTerminated () =
627627
trace "terminating nvim..."
628628
nvim.stop 1
629629

630+
let mutable _detaching = false
631+
630632
let OnTerminating(args: CancelEventArgs) =
631-
args.Cancel <- true
632633
trace "window is closing"
633-
if nvim.isRemote then Detach()
634-
else nvim.quitall() |> ignore
634+
if nvim.isRemote then
635+
if not _detaching then
636+
_detaching <- true
637+
Detach()
638+
else
639+
args.Cancel <- true
640+
nvim.quitall() |> ignore
635641

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

0 commit comments

Comments
 (0)