From 8e4acb2e4dbeddab8130aa09538776b3b880a0b8 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Fri, 19 Apr 2024 16:23:48 -0700 Subject: [PATCH] lwt,eio: remove Client.socket --- eio/gluten_eio.ml | 46 +++++++++++++++++++----------------------- eio/gluten_eio.mli | 1 - lwt/gluten_lwt.ml | 38 +++++++++++++++++----------------- lwt/gluten_lwt_intf.ml | 1 - 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/eio/gluten_eio.ml b/eio/gluten_eio.ml index bbbff4a..1b6e8b9 100644 --- a/eio/gluten_eio.ml +++ b/eio/gluten_eio.ml @@ -74,15 +74,14 @@ module IO_loop = struct (* TODO(anmonteiro): since we stopped failing switches, [sw] is no longer necessary. Consider removing the argument again. *) - let start : - type t. - (module Gluten.RUNTIME with type t = t) - -> read_buffer_size:int - -> read_closed:unit Promise.t * unit Promise.u - -> sw:Eio.Switch.t - -> t - -> _ Eio.Flow.two_way - -> unit + let start : type t. + (module Gluten.RUNTIME with type t = t) + -> read_buffer_size:int + -> read_closed:unit Promise.t * unit Promise.u + -> sw:Eio.Switch.t + -> t + -> _ Eio.Flow.two_way + -> unit = fun (module Runtime) ~read_buffer_size ~read_closed ~sw:_ t socket -> let read_closed, resolve_read_closed = read_closed @@ -176,12 +175,12 @@ module Server = struct type addr = Eio.Net.Sockaddr.stream let create_connection_handler - ~read_buffer_size - ~protocol - ~sw - connection - _client_addr - socket + ~read_buffer_size + ~protocol + ~sw + connection + _client_addr + socket = let connection = Gluten.Server.create ~protocol connection in IO_loop.start @@ -193,13 +192,13 @@ module Server = struct socket let create_upgradable_connection_handler - ~read_buffer_size - ~protocol - ~create_protocol - ~sw - ~request_handler - (client_addr : addr) - socket + ~read_buffer_size + ~protocol + ~create_protocol + ~sw + ~request_handler + (client_addr : addr) + socket = let connection = Gluten.Server.create_upgradable @@ -219,7 +218,6 @@ end module Client = struct type t = { connection : Gluten.Client.t - ; socket : Eio_unix.Net.stream_socket_ty Eio.Net.stream_socket ; shutdown_reader : unit -> unit ; shutdown_complete : unit Promise.t } @@ -240,7 +238,6 @@ module Client = struct connection socket)))); { connection - ; socket ; shutdown_reader = (fun () -> let cancel_reader, resolve_cancel_reader = read_closed in @@ -257,5 +254,4 @@ module Client = struct t.shutdown_complete let is_closed t = Gluten.Client.is_closed t.connection - let socket t = t.socket end diff --git a/eio/gluten_eio.mli b/eio/gluten_eio.mli index 736da2f..1d77e71 100644 --- a/eio/gluten_eio.mli +++ b/eio/gluten_eio.mli @@ -66,5 +66,4 @@ module Client : sig val upgrade : t -> Gluten.impl -> unit val shutdown : t -> unit Eio.Promise.t val is_closed : t -> bool - val socket : t -> Eio_unix.Net.stream_socket_ty Eio.Net.stream_socket end diff --git a/lwt/gluten_lwt.ml b/lwt/gluten_lwt.ml index 5c91e3f..9b4016e 100644 --- a/lwt/gluten_lwt.ml +++ b/lwt/gluten_lwt.ml @@ -47,14 +47,13 @@ module IO_loop = struct (fun n -> Lwt.wakeup_later u n); p - let start : - type t fd. - (module IO with type socket = fd) - -> (module Gluten.RUNTIME with type t = t) - -> t - -> read_buffer_size:int - -> fd - -> unit Lwt.t + let start : type t fd. + (module IO with type socket = fd) + -> (module Gluten.RUNTIME with type t = t) + -> t + -> read_buffer_size:int + -> fd + -> unit Lwt.t = fun (module Io) (module Runtime) t ~read_buffer_size socket -> let read_buffer = Buffer.create read_buffer_size in @@ -122,11 +121,11 @@ module Server (Io : IO) = struct type addr = Io.addr let create_connection_handler - ~read_buffer_size - ~protocol - connection - _client_addr - socket + ~read_buffer_size + ~protocol + connection + _client_addr + socket = let connection = Server.create ~protocol connection in IO_loop.start @@ -137,12 +136,12 @@ module Server (Io : IO) = struct socket let create_upgradable_connection_handler - ~read_buffer_size - ~protocol - ~create_protocol - ~request_handler - client_addr - socket + ~read_buffer_size + ~protocol + ~create_protocol + ~request_handler + client_addr + socket = let connection = Server.create_upgradable @@ -187,5 +186,4 @@ module Client (Io : IO) = struct Io.close t.socket let is_closed t = Client_connection.is_closed t.connection - let socket t = t.socket end diff --git a/lwt/gluten_lwt_intf.ml b/lwt/gluten_lwt_intf.ml index 65fcfa9..55cfab5 100644 --- a/lwt/gluten_lwt_intf.ml +++ b/lwt/gluten_lwt_intf.ml @@ -82,5 +82,4 @@ module type Client = sig val upgrade : t -> Gluten.impl -> unit val shutdown : t -> unit Lwt.t val is_closed : t -> bool - val socket : t -> socket end