Skip to content

Commit

Permalink
Remove Buf_io from the HTTP server (#6064)
Browse files Browse the repository at this point in the history
Cleaning up the attic... It turned out that the `Buf_io` module, while
used in the type signature of every HTTP handler, was not used for
anything useful anymore.

Step by step rationale in the commit messages, so best reviewed commit
by commit.
  • Loading branch information
robhoes authored Oct 18, 2024
2 parents aafb2bb + 8e02455 commit 45d934e
Show file tree
Hide file tree
Showing 28 changed files with 195 additions and 751 deletions.
4 changes: 2 additions & 2 deletions ocaml/database/database_server_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ let _ =
let socket = Http_svr.bind sockaddr "unix_rpc" in
let server = Http_svr.Server.empty () in
Http_svr.Server.add_handler server Http.Post "/post_remote_db_access"
(Http_svr.BufIO remote_database_access_handler_v1) ;
remote_database_access_handler_v1 ;
Http_svr.Server.add_handler server Http.Post "/post_remote_db_access_v2"
(Http_svr.BufIO remote_database_access_handler_v2) ;
remote_database_access_handler_v2 ;
Http_svr.start ~conn_limit:1024 server socket ;
Printf.printf "server listening\n%!" ;
if !self_test then (
Expand Down
5 changes: 2 additions & 3 deletions ocaml/database/db_remote_cache_access_v1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ module DBCacheRemoteListener = struct
raise e
end

let handler req bio _ =
let fd = Buf_io.fd_of bio in
let handler req fd _ =
(* fd only used for writing *)
let body =
Http_svr.read_body ~limit:Db_globs.http_limit_max_rpc_size req bio
Http_svr.read_body ~limit:Db_globs.http_limit_max_rpc_size req fd
in
let body_xml = Xml.parse_string body in
let reply_xml = DBCacheRemoteListener.process_xmlrpc body_xml in
Expand Down
2 changes: 1 addition & 1 deletion ocaml/database/db_remote_cache_access_v1.mli
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
val handler : Http.Request.t -> Buf_io.t -> 'a -> unit
val handler : Http.Request.t -> Unix.file_descr -> 'a -> unit
(** HTTP handler for v1 of the remote DB access protocol *)
5 changes: 2 additions & 3 deletions ocaml/database/db_remote_cache_access_v2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ let process_rpc (req : Rpc.t) =
Response.Too_many_values (x, y, z)
)

let handler req bio _ =
let fd = Buf_io.fd_of bio in
let handler req fd _ =
(* fd only used for writing *)
let body =
Http_svr.read_body ~limit:Db_globs.http_limit_max_rpc_size req bio
Http_svr.read_body ~limit:Db_globs.http_limit_max_rpc_size req fd
in
let request_rpc = Jsonrpc.of_string body in
let reply_rpc = process_rpc request_rpc in
Expand Down
2 changes: 1 addition & 1 deletion ocaml/database/db_remote_cache_access_v2.mli
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
val handler : Http.Request.t -> Buf_io.t -> 'a -> unit
val handler : Http.Request.t -> Unix.file_descr -> 'a -> unit
(** HTTP handler for v2 of the remote DB access protocol *)
157 changes: 0 additions & 157 deletions ocaml/libs/http-lib/buf_io.ml

This file was deleted.

60 changes: 0 additions & 60 deletions ocaml/libs/http-lib/buf_io.mli

This file was deleted.

106 changes: 0 additions & 106 deletions ocaml/libs/http-lib/bufio_test.ml

This file was deleted.

1 change: 0 additions & 1 deletion ocaml/libs/http-lib/bufio_test.mli

This file was deleted.

1 change: 0 additions & 1 deletion ocaml/libs/http-lib/bufio_test_run.ml

This file was deleted.

Empty file.
Loading

0 comments on commit 45d934e

Please sign in to comment.