diff --git a/capnp-rpc-net.opam b/capnp-rpc-net.opam index 28f85fae..78dc4b76 100644 --- a/capnp-rpc-net.opam +++ b/capnp-rpc-net.opam @@ -18,7 +18,6 @@ depends: [ "astring" "fmt" {>= "0.8.7"} "logs" - "asetmap" "cstruct" {>= "6.0.0"} "tls-eio" {>= "1.0.2"} "base64" {>= "3.0.0"} diff --git a/capnp-rpc-net/auth.ml b/capnp-rpc-net/auth.ml index 59e7dcbc..d01b6a34 100644 --- a/capnp-rpc-net/auth.ml +++ b/capnp-rpc-net/auth.ml @@ -1,5 +1,3 @@ -open Asetmap - module Log = Capnp_rpc.Debug.Log let default_rsa_key_bits = 2048 diff --git a/capnp-rpc-net/auth.mli b/capnp-rpc-net/auth.mli index b9aa3062..3d4b2adb 100644 --- a/capnp-rpc-net/auth.mli +++ b/capnp-rpc-net/auth.mli @@ -1,5 +1,3 @@ -open Asetmap - (** Vat-level authentication and encryption. Unless your network provides a secure mechanism for establishing connections diff --git a/capnp-rpc-net/vat.ml b/capnp-rpc-net/vat.ml index 008d3c49..897adf03 100644 --- a/capnp-rpc-net/vat.ml +++ b/capnp-rpc-net/vat.ml @@ -58,7 +58,7 @@ module Make (Network : S.NETWORK) = struct run_connection_generic t endpoint ~add:(fun conn -> t.connections <- ID_map.add peer_id conn t.connections; r conn) ~remove:(fun conn -> - match ID_map.find peer_id t.connections with + match ID_map.find_opt peer_id t.connections with | Some x when x == conn -> t.connections <- ID_map.remove peer_id t.connections | Some _ (* Already replaced by a new one? *) | None -> () @@ -72,7 +72,7 @@ module Make (Network : S.NETWORK) = struct run_connection_generic t endpoint ~add:(fun conn -> t.anon_connections <- conn :: t.anon_connections; r conn) ~remove:(fun conn -> t.anon_connections <- List.filter ((!=) conn) t.anon_connections) - ) else match ID_map.find peer_id t.connections with + ) else match ID_map.find_opt peer_id t.connections with | None -> run_connection_tls t endpoint r | Some existing -> Log.info (fun f -> f ~tags:t.tags "Trying to add a connection, but we already have one for this vat"); @@ -163,7 +163,7 @@ module Make (Network : S.NETWORK) = struct let my_id = Auth.Secret_key.digest ~hash (Lazy.force t.secret_key) in if Auth.Digest.equal remote_id my_id then Restorer.restore t.restore service - else match ID_map.find remote_id t.connections with + else match ID_map.find_opt remote_id t.connections with | Some conn when CapTP.disconnecting conn -> Eio.Condition.await_no_mutex t.connection_removed; connect t (addr, service) @@ -171,7 +171,7 @@ module Make (Network : S.NETWORK) = struct (* Already connected; use that. *) Ok (CapTP.bootstrap conn service) | None -> - match ID_map.find remote_id t.connecting with + match ID_map.find_opt remote_id t.connecting with | None -> initiate_connection t addr service | Some conn -> (* We're already trying to establish a connection, wait for that. *) @@ -218,10 +218,13 @@ module Make (Network : S.NETWORK) = struct Auth.Digest.pp id CapTP.dump conn + let dump_id_map pp f m = + Fmt.pf f "{@[%a@]}" (Fmt.seq pp) (ID_map.to_seq m) + let dump f t = Fmt.pf f "@[%a@,Connecting: %a@,Connected: %a@,Anonymous: %a@]" pp_vat_id t.address - (ID_map.dump dump_connecting) t.connecting - (ID_map.dump dump_id_conn) t.connections + (dump_id_map dump_connecting) t.connecting + (dump_id_map dump_id_conn) t.connections (Fmt.Dump.list CapTP.dump) t.anon_connections end diff --git a/capnp-rpc-unix.opam b/capnp-rpc-unix.opam index 1d4f31a4..a62519cc 100644 --- a/capnp-rpc-unix.opam +++ b/capnp-rpc-unix.opam @@ -23,7 +23,6 @@ depends: [ "alcotest" {>= "1.6.0" & with-test} "mirage-crypto-rng-eio" {>= "1.1.0" & with-test} "mdx" {>= "2.4.1" & with-test} - "asetmap" {with-test} "eio_main" {with-test} "eio" {>= "1.1"} ] diff --git a/capnp-rpc.opam b/capnp-rpc.opam index 1ebd914e..6d17070a 100644 --- a/capnp-rpc.opam +++ b/capnp-rpc.opam @@ -19,7 +19,6 @@ depends: [ "astring" "fmt" {>= "0.8.7"} "logs" - "asetmap" "uri" {>= "1.6.0"} "dune" {>= "3.16"} "alcotest" {>= "1.6.0" & with-test} diff --git a/capnp-rpc/proto/capTP.ml b/capnp-rpc/proto/capTP.ml index 58e41184..f5205c90 100644 --- a/capnp-rpc/proto/capTP.ml +++ b/capnp-rpc/proto/capTP.ml @@ -1,5 +1,3 @@ -open Asetmap - module Log = Debug.Log module IntMap = Map.Make(struct type t = int let compare (a:int) b = compare a b end) @@ -1504,7 +1502,7 @@ module Make (EP : Message_types.ENDPOINT) = struct let caps_used = Question.paths_used question |> caps_used ~msg in let import_with_embargoes cap_index d = let embargo_path = - match IntMap.find cap_index caps_used with + match IntMap.find_opt cap_index caps_used with | None -> None | Some path -> Some (Question.message_target question path) in @@ -1581,7 +1579,7 @@ module Make (EP : Message_types.ENDPOINT) = struct let embargoes_needed = caps_used ~msg paths_used in let maybe_embargo cap_index cap = inc_ref cap; - match IntMap.find cap_index embargoes_needed with + match IntMap.find_opt cap_index embargoes_needed with | None -> cap | Some path -> let old_path = Question.message_target question path in diff --git a/capnp-rpc/proto/dune b/capnp-rpc/proto/dune index 1ba98d6e..c7ad1b49 100644 --- a/capnp-rpc/proto/dune +++ b/capnp-rpc/proto/dune @@ -1,4 +1,4 @@ (library (name capnp_rpc_proto) (public_name capnp-rpc.proto) - (libraries astring fmt logs stdint asetmap threads)) + (libraries astring fmt logs stdint threads)) diff --git a/capnp-rpc/proto/struct_proxy.ml b/capnp-rpc/proto/struct_proxy.ml index e7b996b9..a216f797 100644 --- a/capnp-rpc/proto/struct_proxy.ml +++ b/capnp-rpc/proto/struct_proxy.ml @@ -1,5 +1,3 @@ -open Asetmap - module Log = Debug.Log module Make (C : S.CORE_TYPES) = struct @@ -73,8 +71,6 @@ module Make (C : S.CORE_TYPES) = struct | Forwarding of struct_ref | Finished - let pp_fields = Field_map.dump (fun f (k, v) -> Fmt.pf f "%a:%a" Wire.Path.pp k RC.pp v.ref_count) - let pp_opt_blocked_on f = function | None -> () | Some b -> Fmt.pf f " (blocked on %t)" b#pp @@ -239,7 +235,7 @@ module Make (C : S.CORE_TYPES) = struct dispatch state ~unresolved:(fun u -> let field = - match Field_map.find path u.fields with + match Field_map.find_opt path u.fields with | Some f -> f | None -> let cap = field path (self :> struct_ref_internal) in @@ -393,7 +389,7 @@ module Make (C : S.CORE_TYPES) = struct ~unresolved:(fun u -> (* When we resolve, we'll be holding references to all the caps in the resolution, so so they must still be alive by the time we pass on any extra inc or dec refs. *) - let f = Field_map.get path u.fields in + let f = Field_map.find path u.fields in assert (f.ref_count > RC.one); (* rc can't be one because that's our reference *) let pp = self#field_pp path in f.ref_count <- RC.sum f.ref_count d ~pp @@ -406,7 +402,7 @@ module Make (C : S.CORE_TYPES) = struct method field_dec_ref path = dispatch state ~unresolved:(fun u -> - let f = Field_map.get path u.fields in + let f = Field_map.find path u.fields in assert (f.ref_count > RC.one); (* rc can't be one because that's our reference *) let pp = self#field_pp path in f.ref_count <- RC.pred f.ref_count ~pp @@ -424,7 +420,7 @@ module Make (C : S.CORE_TYPES) = struct method field_check_invariants i = dispatch state ~unresolved:(fun u -> - let f = Field_map.get i u.fields in + let f = Field_map.find i u.fields in assert (f.ref_count > RC.one); self#check_invariants ) @@ -435,7 +431,7 @@ module Make (C : S.CORE_TYPES) = struct | Finished -> Fmt.pf f "Promise is finished, but field %a isn't!" Wire.Path.pp path | Forwarding _ -> Fmt.pf f "Promise is resolved, but field %a isn't!" Wire.Path.pp path | Unresolved u -> - let field = Field_map.get path u.fields in + let field = Field_map.find path u.fields in match RC.to_int field.ref_count with | None -> Fmt.pf f "(rc=LEAKED) -> #%a -> %t" Wire.Path.pp path self#pp diff --git a/fuzz/fuzz.ml b/fuzz/fuzz.ml index 93089cd9..d364dfde 100644 --- a/fuzz/fuzz.ml +++ b/fuzz/fuzz.ml @@ -1,4 +1,3 @@ -open Asetmap module RO_array = Capnp_rpc_proto.RO_array module Test_utils = Testbed.Test_utils module OID = Capnp_rpc_proto.Debug.OID diff --git a/test/proto/testbed/dune b/test/proto/testbed/dune index 05c7faf0..0127df9a 100644 --- a/test/proto/testbed/dune +++ b/test/proto/testbed/dune @@ -1,3 +1,3 @@ (library (name testbed) - (libraries astring fmt logs logs.fmt capnp-rpc.proto alcotest asetmap)) + (libraries astring fmt logs logs.fmt capnp-rpc.proto alcotest))