mirror of
https://github.com/c-cube/nanoev.git
synced 2025-12-06 03:05:32 -05:00
improve server
This commit is contained in:
parent
c8d88e3887
commit
299dd9dddb
3 changed files with 13 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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 :
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue