Skip to content

Commit

Permalink
Force users to give a custom callback in case of exception to avoid r…
Browse files Browse the repository at this point in the history
…andom crashes
  • Loading branch information
kit-ty-kate committed Jul 19, 2019
1 parent 05ddf13 commit 07a1925
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lwt-unix/conduit_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,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
Expand Down
8 changes: 4 additions & 4 deletions lwt-unix/conduit_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type tcp_config = [
| `Socket of Lwt_unix.file_descr sexp_opaque
] [@@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.
Expand Down Expand Up @@ -166,18 +166,18 @@ 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
lightweight thread that is invoked via the [fn] callback. The
[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
Expand Down

0 comments on commit 07a1925

Please sign in to comment.