Unix.accept may raise an exception (typicall Unix.EINTR, even with sigpipe blocked ?)

This avoids the server to stop
This commit is contained in:
craff 2021-11-29 15:35:41 -10:00
parent a58372b9a7
commit 6ccd8314a3

View file

@ -1088,6 +1088,7 @@ let run (self:t) : (unit,_) result =
while self.running do
(* limit concurrency *)
Sem_.acquire 1 self.sem_max_connections;
try
let client_sock, _ = Unix.accept sock in
self.new_thread
(fun () ->
@ -1099,6 +1100,9 @@ let run (self:t) : (unit,_) result =
Sem_.release 1 self.sem_max_connections;
raise e
);
with e ->
Printf.eprintf "accept raised an exception: %s"
(Printexc.to_string e)
done;
Ok ()
with e -> Error e