Skip to content

Commit 956160a

Browse files
committed
fix: stop leaking fd's
Signed-off-by: Rudi Grinberg <[email protected]> ps-id: 0C81D980-D58D-4F4F-BB44-2F886676526D
1 parent 9762f8e commit 956160a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.11.6
2+
3+
- Stop leaking file descriptors like a sieve (#701)
4+
15
# 1.11.5
26

37
- Fix process termination. Once the lsp server is stepped, the process will

ocaml-lsp-server/src/dune.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,20 @@ end = struct
366366
| `Unix s -> Unix.ADDR_UNIX s
367367
| `Ip (`Host h, `Port p) -> Unix.ADDR_INET (Unix.inet_addr_of_string h, p)
368368
in
369+
let sock =
370+
let domain = Unix.domain_of_sockaddr sockaddr in
371+
let socket = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in
372+
Lev_fiber.Fd.create socket (`Non_blocking false)
373+
in
369374
let* session =
370-
let sock =
371-
let domain = Unix.domain_of_sockaddr sockaddr in
372-
let socket = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in
373-
Lev_fiber.Fd.create socket (`Non_blocking false)
374-
in
375375
Fiber.map_reduce_errors
376376
(module Monoid.List (Exn_with_backtrace))
377377
~on_error:(fun exn -> Fiber.return [ exn ])
378378
(fun () -> Csexp_rpc.connect sock sockaddr)
379379
in
380380
match session with
381381
| Error exns ->
382+
Lev_fiber.Fd.close sock;
382383
let message =
383384
let exn = List.hd exns in
384385
Format.asprintf "unable to connect to dune %s@.%a"

0 commit comments

Comments
 (0)