Skip to content
Browse files

Fix bug in Watchman_lwt.close_connection

Summary: There was a bug in `Watchman_lwt` which would cause `EBADF` (error, bad file descriptor) to be thrown when closing a connection via `Watchman_lwt`. Since we never would purposely close a connection, we weren't hitting this.

Reviewed By: samwgoldman

Differential Revision: D13060172

fbshipit-source-id: fc6a75b9cfe6b31b7cd9d2b13b23452366a3dbce
  • Loading branch information
gabelevi authored and hhvm-bot committed Nov 15, 2018
1 parent f0362fc commit e6dd48c84e5fc3189b03ab54e5f436c022f0e4b6
Showing with 4 additions and 1 deletion.
  1. +4 −1 hphp/hack/src/watchman/
@@ -80,7 +80,10 @@ struct

let close_connection (reader, oc) =
let%lwt () = Lwt_unix.close @@ Buffered_line_reader_lwt.get_fd reader in
Lwt_io.close oc
(* As mention above, if we open the connection with Unix.open_connection, we use a single fd for
* both input and output. That means we might be trying to close it twice here. If so, this
* second close with throw. So let's catch that exception and ignore it. *)
try%lwt Lwt_io.close oc with Unix.Unix_error(Unix.EBADF, _, _) -> Lwt.return_unit

let with_watchman_conn ~timeout f =
let%lwt conn = open_connection ~timeout in

0 comments on commit e6dd48c

Please sign in to comment.