Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force users to give a custom callback in case of exception to avoid random crashes #261

Merged
merged 1 commit into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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