Skip to content

Commit

Permalink
Merge pull request #5112 from lindig/private/christianlin/stunnel-cache
Browse files Browse the repository at this point in the history
Document parameters in Stunnel_cache API
  • Loading branch information
robhoes authored Jul 14, 2023
2 parents ebe822b + 941a170 commit a36bae1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ocaml/database/master_connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let force_connection_reset () =
host and port are fixed values. *)
let rec purge_stunnels verify_cert =
match
Stunnel_cache.with_remove host port verify_cert @@ fun st ->
Stunnel_cache.with_remove ~host ~port verify_cert @@ fun st ->
try Stunnel.disconnect ~wait:false ~force:true st with _ -> ()
with
| None ->
Expand Down
2 changes: 1 addition & 1 deletion ocaml/libs/http-lib/xmlrpc_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ let with_reusable_stunnel ?use_fork_exec_helper ?write_to_log ?verify_cert host
(* 1. First check if there is a suitable stunnel in the cache. *)
let rec loop () =
match
Stunnel_cache.with_remove host port verify_cert @@ fun x ->
Stunnel_cache.with_remove ~host ~port verify_cert @@ fun x ->
if check_reusable x.Stunnel.fd (Stunnel.getpid x.Stunnel.pid) then
Ok (f x)
else (
Expand Down
7 changes: 4 additions & 3 deletions ocaml/libs/stunnel/stunnel_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ let add (x : Stunnel.t) =
(** Returns an Stunnel.t for this endpoint (oldest first), raising Not_found
if none can be found. First performs a garbage-collection, which discards
expired stunnels if needed. *)
let with_remove host port verified f =
let with_remove ~host ~port verified f =
let ep = {host; port; verified} in
let get_id () =
with_lock m (fun () ->
Expand Down Expand Up @@ -239,8 +239,9 @@ let flush () =
info "Flushed!"
)

let with_connect ?use_fork_exec_helper ?write_to_log ~verify_cert host port f =
match with_remove host port verify_cert f with
let with_connect ?use_fork_exec_helper ?write_to_log ~verify_cert ~host ~port f
=
match with_remove ~host ~port verify_cert f with
| Some r ->
r
| None ->
Expand Down
15 changes: 7 additions & 8 deletions ocaml/libs/stunnel/stunnel_cache.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

(** Operate a small cache of stunnels so we can re-use them for repeated calls.
Caveats:
* stunnel donators should only donate stunnels which they knows are connected
to the main HTTP request loop in the server -- HTTP 1.1 should be used and
the connection should be kept-alive.
Caveats: stunnel donators should only donate stunnels which they
knows are connected to the main HTTP request loop in the server --
HTTP 1.1 should be used and the connection should be kept-alive.
*)

val with_connect :
?use_fork_exec_helper:bool
-> ?write_to_log:(string -> unit)
-> verify_cert:Stunnel.verification_config option
-> string
-> int
-> host:string (** host *)
-> port:int (** port *)
-> (Stunnel.t -> 'b)
-> 'b
(** Connects via stunnel (optionally via an external 'fork/exec helper') to
Expand All @@ -36,8 +35,8 @@ val add : Stunnel.t -> unit
(** Adds a reusable stunnel to the cache *)

val with_remove :
string
-> int
host:string (** host *)
-> port:int (** port *)
-> Stunnel.verification_config option
-> (Stunnel.t -> 'b)
-> 'b option
Expand Down

0 comments on commit a36bae1

Please sign in to comment.