diff --git a/src/picos/base.ml b/src/picos/base.ml index a34577f..142e467 100644 --- a/src/picos/base.ml +++ b/src/picos/base.ml @@ -13,7 +13,11 @@ let[@unroll 1] rec retry_read_ fd f = match f () with | res -> res | exception - Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK | Unix.EINTR), _, _) -> + Unix.Unix_error + ( ( Unix.EAGAIN | Unix.EWOULDBLOCK | Unix.EINTR | Unix.EINPROGRESS + | Unix.ECONNRESET ), + _, + _ ) -> (* Trace_.message "read must wait"; *) let trigger = Picos.Trigger.create () in let closed_r = ref false in @@ -29,7 +33,11 @@ let[@unroll 1] rec retry_write_ fd f = match f () with | res -> res | exception - Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK | Unix.EINTR), _, _) -> + Unix.Unix_error + ( ( Unix.EAGAIN | Unix.EWOULDBLOCK | Unix.EINTR | Unix.EINPROGRESS + | Unix.ECONNRESET ), + _, + _ ) -> (* Trace_.message "write must wait"; *) let ev = get_loop_exn_ () in let trigger = Picos.Trigger.create () in diff --git a/src/picos/net_server.ml b/src/picos/net_server.ml index 8c91799..ca74b0c 100644 --- a/src/picos/net_server.ml +++ b/src/picos/net_server.ml @@ -8,9 +8,8 @@ type t = { mutable running: unit Picos.Computation.t option; } -let shutdown (self : t) = - if Atomic.exchange self.active false then - Option.iter Picos.Computation.await self.running +let join (self : t) : unit = Option.iter Picos.Computation.await self.running +let shutdown (self : t) = if Atomic.exchange self.active false then () open struct let run (self : t) () : unit = diff --git a/src/picos/net_server.mli b/src/picos/net_server.mli index 7432335..178fc0d 100644 --- a/src/picos/net_server.mli +++ b/src/picos/net_server.mli @@ -1,6 +1,7 @@ type client_handler = Unix.sockaddr -> IO_in.t -> IO_out.t -> unit type t +val join : t -> unit val shutdown : t -> unit val establish :