Skip to content
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 happy-eyeballs-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ doc: "https://roburio.github.io/happy-eyeballs/"
license: "ISC"

depends: [
"ocaml" {>= "4.10.0"}
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"happy-eyeballs" {=version}
"cmdliner"
Expand Down
2 changes: 1 addition & 1 deletion happy-eyeballs-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ doc: "https://roburio.github.io/happy-eyeballs/"
license: "ISC"

depends: [
"ocaml" {>= "4.10.0"}
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"happy-eyeballs" {=version}
"duration"
Expand Down
2 changes: 1 addition & 1 deletion happy-eyeballs.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ doc: "https://roburio.github.io/happy-eyeballs/"
license: "ISC"

depends: [
"ocaml" {>= "4.10.0"}
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"duration"
"domain-name" {>= "0.2.0"}
Expand Down
8 changes: 4 additions & 4 deletions lwt/happy_eyeballs_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ let handle_timer_actions t actions =
let rec timer t =
let open Lwt.Infix in
let rec loop () =
let he, actions = Happy_eyeballs.timer t.he (now ()) in
let he, cont, actions = Happy_eyeballs.timer t.he (now ()) in
t.he <- he ;
match actions with
handle_timer_actions t actions ;
match cont with
| `Suspend ->
timer t
| `Act actions ->
handle_timer_actions t actions ;
| `Act ->
Lwt_unix.sleep t.timer_interval >>= fun () ->
loop ()
in
Expand Down
8 changes: 4 additions & 4 deletions mirage/happy_eyeballs_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ module Make (R : Mirage_random.S) (T : Mirage_time.S) (C : Mirage_clock.MCLOCK)
let rec timer t =
let open Lwt.Infix in
let rec loop () =
let he, actions = Happy_eyeballs.timer t.he (C.elapsed_ns ()) in
let he, cont, actions = Happy_eyeballs.timer t.he (C.elapsed_ns ()) in
t.he <- he ;
match actions with
handle_timer_actions t actions ;
match cont with
| `Suspend ->
timer t
| `Act actions ->
handle_timer_actions t actions ;
| `Act ->
T.sleep_ns t.timer_interval >>= fun () ->
loop ()
in
Expand Down
8 changes: 3 additions & 5 deletions src/happy_eyeballs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ let add_conn host id conn c =
c

let expand_list ips ports =
List.concat_map (fun ip -> List.map (fun p -> (ip, p)) ports) ips
List.flatten (List.map (fun ip -> List.map (fun p -> (ip, p)) ports) ips)

(* all input has been verified that ips and ports are non-empty. *)
let expand_list_split ips ports =
Expand Down Expand Up @@ -181,10 +181,8 @@ let timer t now =
in
Log.debug (fun m -> m "timer %d actions" (List.length actions));
{ t with conns },
if Domain_name.Host_map.is_empty conns then
(assert (actions = []); `Suspend)
else
`Act actions
(if Domain_name.Host_map.is_empty conns then `Suspend else `Act),
actions

let connect t now ~id host ports =
if ports = [] then failwith "empty port list not supported";
Expand Down
9 changes: 5 additions & 4 deletions src/happy_eyeballs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ val create : ?aaaa_timeout:int64 -> ?connect_timeout:int64 ->
[connect_timeout] and [resolve_timeout] use a default of
[Duration.of_sec 1]. *)

val timer : t -> int64 -> t * [ `Suspend | `Act of action list ]
val timer : t -> int64 -> t * [ `Suspend | `Act ] * action list
(** [timer t ts] is a timer function that results in an updated [t] and either
[`Suspend] signalling the timer thread can sleep or [`Act actions] a list
of actions that need to be performed (connection to be retried, connection
failures to be reported, ...).
[`Suspend] signalling the timer thread can sleep or [`Act] that the timer
should be called again. In addition, a list of actions that need to be
performed (connection to be retried, connection failures to be reported,
...) is provided.
The timer thread should be signalled to resume after calling [connect] or
[connect_ip]. *)

Expand Down