Skip to content

Commit 1a4f62a

Browse files
committed
Remove all Mirage_time.S and Mirage_clock.S
Signed-off-by: Patrick Ferris <patrick@sirref.org>
1 parent 24caf7a commit 1a4f62a

54 files changed

Lines changed: 317 additions & 337 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dune-project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
(lang dune 2.0)
1+
(lang dune 3.4)
2+
23
(name vpnkit)

dune-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(lang dune 3.4)
2+
(env
3+
(dev
4+
(flags
5+
(:standard -warn-error +A-67-69))) ; Disable some unused warnings.
6+
(release
7+
(flags
8+
(:standard -warn-error +A-58))))

scripts/licenses.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,11 +1155,6 @@ let speclist =
11551155
[("-out", Arg.Set_string output_file, "Set output file name");
11561156
("-in", Arg.Set_string input_file, "Set input file name")]
11571157

1158-
let run cmd = match Unix.system cmd with
1159-
| Unix.WEXITED 0 -> ()
1160-
| Unix.WEXITED n -> failwith (Printf.sprintf "%s: %d" cmd n)
1161-
| _ -> failwith (Printf.sprintf "%s: unexpected signal" cmd)
1162-
11631158
let trim_comment line = match Stringext.cut ~on:"#" line with
11641159
| None -> line
11651160
| Some (line, _comment) -> line

src/bin/connect.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module Hvsock = struct
4646
(* Avoid using `detach` because we don't want to exhaust the
4747
thread pool since this will block the main TCP/IP stack. *)
4848
module F =
49-
Hvsock_lwt.Flow_shutdown.Make(Host.Time)
49+
Hvsock_lwt.Flow_shutdown.Make
5050
(Hvsock_lwt.In_main_thread.Make(Host.Main))
5151
(Hvsock.Af_hyperv)
5252

src/bin/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(executable
22
(name main)
33
(libraries cmdliner ofs logs.fmt hostnet hvsock hvsock.lwt
4-
fd-send-recv duration mirage-clock-unix mirage-random
5-
fs9p mirage-random-stdlib)
4+
fd-send-recv duration
5+
fs9p)
66
(flags
77
:standard
88
(:include flags.sexp))

src/bin/main.ml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ let hvsock_addr_of_uri ~default_serviceid uri =
5555
module Connect_hvsock = Connect.Hvsock
5656
module Bind = Bind.Make(Host.Sockets)
5757
module Dns_policy = Hostnet_dns.Policy(Host.Files)
58-
module Forward_unix = Forward.Make(Mclock)(Connect_unix)(Bind)
59-
module Forward_hvsock = Forward.Make(Mclock)(Connect_hvsock)(Bind)
60-
module HV = Hvsock_lwt.Flow.Make(Host.Time)(Host.Fn)(Hvsock.Af_hyperv)
61-
module HV_generic = Hvsock_lwt.Flow.Make(Host.Time)(Host.Fn)(Hvsock.Socket)
58+
module Forward_unix = Forward.Make(Connect_unix)(Bind)
59+
module Forward_hvsock = Forward.Make(Connect_hvsock)(Bind)
60+
module HV = Hvsock_lwt.Flow.Make(Host.Fn)(Hvsock.Af_hyperv)
61+
module HV_generic = Hvsock_lwt.Flow.Make(Host.Fn)(Hvsock.Socket)
6262
module HostsFile = Hosts.Make(Host.Files)
6363

6464
let file_descr_of_int (x: int) : Unix.file_descr =
@@ -100,7 +100,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
100100
| x -> Lwt.return x
101101
| exception e ->
102102
Log.err (fun f -> f "Caught %s while creating Hyper-V socket" (Printexc.to_string e));
103-
Host.Time.sleep_ns (Duration.of_sec 1)
103+
Mirage_sleep.ns (Duration.of_sec 1)
104104
>>= fun () ->
105105
loop () in
106106
loop ()
@@ -126,7 +126,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
126126
(Hvsock.Af_hyperv.string_of_sockaddr sockaddr));
127127
log_exception_continue "HV.Socket.close" (fun () -> HV.Socket.close socket)
128128
>>= fun () ->
129-
Host.Time.sleep_ns (Duration.of_sec 1)
129+
Mirage_sleep.ns (Duration.of_sec 1)
130130
)
131131
>>= fun () ->
132132
aux () in
@@ -138,7 +138,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
138138
| x -> Lwt.return x
139139
| exception e ->
140140
Log.err (fun f -> f "Caught %s while creating hypervisor socket" (Printexc.to_string e));
141-
Host.Time.sleep_ns (Duration.of_sec 1)
141+
Mirage_sleep.ns (Duration.of_sec 1)
142142
>>= fun () ->
143143
loop () in
144144
loop ()
@@ -165,7 +165,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
165165
(Hvsock.Socket.string_of_sockaddr sockaddr));
166166
log_exception_continue "HV_generic.Socket.close" (fun () -> HV_generic.Socket.close socket)
167167
>>= fun () ->
168-
Host.Time.sleep_ns (Duration.of_sec 1)
168+
Mirage_sleep.ns (Duration.of_sec 1)
169169
)
170170
>>= fun () ->
171171
aux () in
@@ -187,11 +187,11 @@ let hvsock_addr_of_uri ~default_serviceid uri =
187187
| Unix.Unix_error(_, _, _) ->
188188
log_exception_continue "HV.Socket.close" (fun () -> HV.Socket.close socket)
189189
>>= fun () ->
190-
Host.Time.sleep_ns (Duration.of_sec 1)
190+
Mirage_sleep.ns (Duration.of_sec 1)
191191
| _ ->
192192
log_exception_continue "HV.Socket.close" (fun () -> HV.Socket.close socket)
193193
>>= fun () ->
194-
Host.Time.sleep_ns (Duration.of_sec 1)
194+
Mirage_sleep.ns (Duration.of_sec 1)
195195
)
196196
>>= fun () ->
197197
aux ()
@@ -398,8 +398,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
398398
match Uri.scheme uri with
399399
| Some ("hyperv-connect"|"hyperv-listen") ->
400400
let module Slirp_stack =
401-
Slirp.Make(Vmnet.Make(HV))(Dns_policy)
402-
(Mclock)(Mirage_random_stdlib)(Vnet)
401+
Slirp.Make(Vmnet.Make(HV))(Dns_policy)(Vnet)
403402
in
404403
let sockaddr =
405404
hvsock_addr_of_uri ~default_serviceid:ethernet_serviceid
@@ -431,8 +430,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
431430
else hvsock_listen sockaddr callback
432431
| Some "fd" | None ->
433432
let module Slirp_stack =
434-
Slirp.Make(Vmnet.Make(Host.Sockets.Stream.Unix))(Dns_policy)
435-
(Mclock)(Mirage_random_stdlib)(Vnet)
433+
Slirp.Make(Vmnet.Make(Host.Sockets.Stream.Unix))(Dns_policy)(Vnet)
436434
in
437435
begin match http_intercept_api_path with
438436
| None -> ()
@@ -466,8 +464,7 @@ let hvsock_addr_of_uri ~default_serviceid uri =
466464
end
467465
| _ ->
468466
let module Slirp_stack =
469-
Slirp.Make(Vmnet.Make(HV_generic))(Dns_policy)
470-
(Mclock)(Mirage_random_stdlib)(Vnet)
467+
Slirp.Make(Vmnet.Make(HV_generic))(Dns_policy)(Vnet)
471468
in
472469
Slirp_stack.create_static vnet_switch configuration
473470
>>= fun stack_config ->

src/dns_forward/dns_forward.mli

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,14 @@ module Rpc: sig
215215
module Persistent: sig
216216
module Make
217217
(Flow: Flow.Client with type address = Ipaddr.t * int)
218-
(Framing: Framing.S with type flow = Flow.flow)
219-
(Time: Mirage_time.S): S
218+
(Framing: Framing.S with type flow = Flow.flow) : S
220219
(** Construct a multiplexing RPC client given a Flow and a method of Framing messages
221220
over the flow. *)
222221
end
223222
module Nonpersistent: sig
224223
module Make
225224
(Flow: Flow.Client with type address = Ipaddr.t * int)
226-
(Framing: Framing.S with type flow = Flow.flow)
227-
(Time: Mirage_time.S): S
225+
(Framing: Framing.S with type flow = Flow.flow): S
228226
(** Construct an RPC client given a Flow which sends one message per fresh connection
229227
over the flow. *)
230228
end
@@ -259,8 +257,7 @@ module Rpc: sig
259257

260258
module Make
261259
(Flow: Flow.Server with type address = Ipaddr.t * int)
262-
(Framing: Framing.S with type flow = Flow.flow)
263-
(Time: Mirage_time.S): S
260+
(Framing: Framing.S with type flow = Flow.flow): S
264261
(** Construct an RPC server given a Flow and a method of Framing messages
265262
over the flow. *)
266263
end
@@ -297,10 +294,7 @@ module Resolver: sig
297294
end
298295

299296
module Make
300-
(Client: Rpc.Client.S)
301-
(Time : Mirage_time.S)
302-
(Clock : Mirage_clock.MCLOCK):
303-
S
297+
(Client: Rpc.Client.S) : S
304298
(** Construct a DNS resolver which will use the given [Client] Implementation
305299
to contact upstream servers, and the given [Time] implementation to handle
306300
timeouts. *)

src/dns_forward/dns_forward_cache.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type answer = {
3737
timeout: unit Lwt.t;
3838
}
3939

40-
module Make(Time: Mirage_time.S) = struct
4140
type t = {
4241
max_bindings: int;
4342
(* For every question we store a mapping of server address to the answer *)
@@ -89,7 +88,7 @@ module Make(Time: Mirage_time.S) = struct
8988
in
9089
let timeout =
9190
let open Lwt.Infix in
92-
Time.sleep_ns (Duration.of_sec @@ Int32.to_int min_ttl)
91+
Mirage_sleep.ns (Duration.of_sec @@ Int32.to_int min_ttl)
9392
>>= fun () ->
9493
if Question.Map.mem question t.cache then begin
9594
let address_to_answer =
@@ -109,4 +108,3 @@ module Make(Time: Mirage_time.S) = struct
109108
in
110109
t.cache <- Question.Map.add question
111110
(Address.Map.add address answer address_to_answer) t.cache
112-
end

src/dns_forward/dns_forward_cache.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*
1616
*)
1717

18-
module Make(Time: Mirage_time.S): sig
1918
type t
2019
(** A cache of DNS answers *)
2120

@@ -32,4 +31,3 @@ module Make(Time: Mirage_time.S): sig
3231

3332
val insert: t -> Dns_forward_config.Address.t -> Dns.Packet.question -> Dns.Packet.rr list -> unit
3433
(** Insert the answer to the question into the cache *)
35-
end

src/dns_forward/dns_forward_resolver.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ let or_fail_msg m = m >>= function
7272
module type S = Dns_forward_s.RESOLVER
7373

7474
module Make
75-
(Client: Dns_forward_s.RPC_CLIENT)
76-
(Time : Mirage_time.S)
77-
(Clock : Mirage_clock.MCLOCK) =
75+
(Client: Dns_forward_s.RPC_CLIENT) =
7876
struct
7977

80-
module Cache = Dns_forward_cache.Make(Time)
78+
module Cache = Dns_forward_cache
8179
type address = Dns_forward_config.Address.t
8280
type message_cb = ?src:address -> ?dst:address -> buf:Cstruct.t -> unit -> unit Lwt.t
8381

@@ -153,7 +151,7 @@ struct
153151
| None ->
154152
let c = List.find (fun c -> c.server = server) t.connections in
155153
begin
156-
let now_ns = Clock.elapsed_ns () in
154+
let now_ns = Mirage_mtime.elapsed_ns () in
157155
(* If no timeout is configured, we will stop listening after
158156
5s to avoid leaking threads if a server is offline *)
159157
let timeout_ns =
@@ -177,11 +175,11 @@ struct
177175
in
178176
make 0L in
179177
let requests = List.map (fun delay_ns ->
180-
Time.sleep_ns delay_ns >>= fun () ->
178+
Mirage_sleep.ns delay_ns >>= fun () ->
181179
Client.rpc c.client buffer
182180
) delays_ns in
183181
let timeout =
184-
Time.sleep_ns timeout_ns >|= fun () ->
182+
Mirage_sleep.ns timeout_ns >|= fun () ->
185183
Error (`Msg "timeout")
186184
in
187185
Lwt.pick (timeout :: requests)

0 commit comments

Comments
 (0)