Skip to content

Commit 323e271

Browse files
committed
perf: use sendfile to forward
1 parent 8342463 commit 323e271

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

lua/fzf-lua/rpc.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,19 @@ local function server_listen(server_socket, server_socket_path)
3434
if tmpdir and #tmpdir > 0 then uv.fs_rmdir(tmpdir) end
3535
end
3636

37-
receive_socket:read_start(function(err, data)
38-
assert(not err)
39-
if not data then
37+
while true do
38+
local len = uv.fs_sendfile(1, receive_socket:fileno(), 0, 1024 * 1024)
39+
local eof = len == 0
40+
if eof then
4041
uv.close(receive_socket)
4142
uv.close(server_socket)
4243
-- on windows: ci fail when use uv.stop()
4344
-- on linux: zero event can freeze
4445
-- https://github.com/ibhagwan/fzf-lua/pull/1955#issuecomment-2785474217
4546
-- uv.stop()
4647
os.exit(0)
47-
return
4848
end
49-
io.write(data)
50-
end)
49+
end
5150
end)
5251
end
5352

@@ -97,8 +96,12 @@ local rpc_nvim_exec_lua = function(opts)
9796
os.exit(1)
9897
end
9998

100-
uv.run("once")
101-
uv.run() -- noreturn, quit by os.exit
99+
-- uv.run("once")
100+
-- uv.run() -- noreturn, quit by os.exit
101+
102+
while true do
103+
vim.wait(100)
104+
end
102105
end
103106

104107
local args = vim.deepcopy(_G.arg)

0 commit comments

Comments
 (0)