From 9377a4cfd006a9c967856b073b5bcc5edfabd741 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 18 Apr 2018 18:19:15 +0100 Subject: [PATCH] Force users to give a custom callback in case of exception to avoid random crashes --- lwt-unix/conduit_lwt_unix.ml | 2 +- lwt-unix/conduit_lwt_unix.mli | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lwt-unix/conduit_lwt_unix.ml b/lwt-unix/conduit_lwt_unix.ml index 5375299d..ea8a37cb 100644 --- a/lwt-unix/conduit_lwt_unix.ml +++ b/lwt-unix/conduit_lwt_unix.ml @@ -283,7 +283,7 @@ let serve_with_default_tls ?timeout ?stop ~ctx ~certfile ~keyfile | No_tls -> failwith "No SSL or TLS support compiled into Conduit" let serve ?backlog ?timeout ?stop - ?(on_exn=(fun exn -> !Lwt.async_exception_hook exn)) + ~on_exn ~(ctx:ctx) ~(mode:server) callback = let callback flow ic oc = Lwt.catch diff --git a/lwt-unix/conduit_lwt_unix.mli b/lwt-unix/conduit_lwt_unix.mli index af9b45b5..90316b0e 100644 --- a/lwt-unix/conduit_lwt_unix.mli +++ b/lwt-unix/conduit_lwt_unix.mli @@ -71,7 +71,7 @@ type server_tls_config = [ `Port of int ] [@@deriving sexp] -(** Set of supported listening mechanisms that are supported by this module. +(** Set of supported listening mechanisms that are supported by this module. - [`TLS server_tls_config]: Use OCaml-TLS or OpenSSL (depending on CONDUIT_TLS) to connect to the given [host], [ip], [port] tuple via TCP. - [`TLS_native _]: Force use of native OCaml TLS stack to connect. @@ -156,7 +156,7 @@ val init : ?src:string -> ?tls_server_key:tls_server_key -> unit -> ctx io via the [ctx] context to the endpoint described by [client] *) val connect : ctx:ctx -> client -> (flow * ic * oc) io -(** [serve ?backlog ?timeout ?stop ?on_exn ~ctx ~mode fn] +(** [serve ?backlog ?timeout ?stop ~on_exn ~ctx ~mode fn] establishes a listening connection of type [mode], using the [ctx] context. The [stop] thread will terminate the server if it ever becomes determined. Every connection will be served in a new @@ -164,10 +164,10 @@ val connect : ctx:ctx -> client -> (flow * ic * oc) io [fn] callback is passed the {!flow} representing the client connection and the associated input {!ic} and output {!oc} channels. If the callback raises an exception, it is passed to - [on_exn] (by default, to !Lwt.async_exception_hook). *) + [on_exn]. *) val serve : ?backlog:int -> ?timeout:int -> ?stop:(unit io) -> - ?on_exn:(exn -> unit) -> ctx:ctx -> mode:server -> + on_exn:(exn -> unit) -> ctx:ctx -> mode:server -> (flow -> ic -> oc -> unit io) -> unit io (** [set_max_active nconn] sets the maximum number of active connections