From de9760d786187601c39d4e3cd47eed35a589b2d9 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 15 Aug 2024 09:18:15 -0400 Subject: [PATCH] format --- src/Tiny_httpd.ml | 4 ++-- src/camlzip/dune | 7 ++++--- src/core/dune | 21 +++++++++++++-------- src/dune | 18 +++++++++++------- src/html/dune | 10 ++++------ src/prometheus/dune | 9 +++++---- src/unix/dune | 25 ++++++++++++++----------- src/unix/mime_.mli | 3 +-- src/unix/tiny_httpd_unix.ml | 8 ++++---- src/ws/dune | 23 ++++++++++++----------- tests/prometheus/dune | 5 ++--- tests/unit/dune | 7 +++---- tests/unit/util/dune | 7 +++---- tests/unit/ws/dune | 9 ++++----- 14 files changed, 82 insertions(+), 74 deletions(-) diff --git a/src/Tiny_httpd.ml b/src/Tiny_httpd.ml index 6d8cd7c2..36b6ca8a 100644 --- a/src/Tiny_httpd.ml +++ b/src/Tiny_httpd.ml @@ -27,8 +27,8 @@ open struct slice.len <- 0 end -let create ?(masksigpipe = not (Sys.win32)) ?max_connections ?(timeout = 0.0) ?buf_size - ?(get_time_s = Unix.gettimeofday) +let create ?(masksigpipe = not Sys.win32) ?max_connections ?(timeout = 0.0) + ?buf_size ?(get_time_s = Unix.gettimeofday) ?(new_thread = fun f -> ignore (Thread.create f () : Thread.t)) ?(addr = "127.0.0.1") ?(port = 8080) ?sock ?middlewares () : t = let max_connections = get_max_connection_ ?max_connections () in diff --git a/src/camlzip/dune b/src/camlzip/dune index eb0ad106..8049a58d 100644 --- a/src/camlzip/dune +++ b/src/camlzip/dune @@ -3,6 +3,7 @@ (public_name tiny_httpd_camlzip) (synopsis "A wrapper around camlzip to bring compression to Tiny_httpd") (flags :standard -open Tiny_httpd_core -safe-string -warn-error -a+8) - (libraries (re_export tiny_httpd.core) - (re_export iostream-camlzip) - camlzip)) + (libraries + (re_export tiny_httpd.core) + (re_export iostream-camlzip) + camlzip)) diff --git a/src/core/dune b/src/core/dune index a04707ef..757eb8e5 100644 --- a/src/core/dune +++ b/src/core/dune @@ -1,12 +1,17 @@ - (library - (name tiny_httpd_core) - (public_name tiny_httpd.core) - (private_modules parse_ common_) - (libraries threads seq hmap iostream - (select log.ml from - (logs -> log.logs.ml) - (-> log.default.ml)))) + (name tiny_httpd_core) + (public_name tiny_httpd.core) + (private_modules parse_ common_) + (libraries + threads + seq + hmap + iostream + (select + log.ml + from + (logs -> log.logs.ml) + (-> log.default.ml)))) (rule (targets Atomic_.ml) diff --git a/src/dune b/src/dune index c705d70d..1e38b1ef 100644 --- a/src/dune +++ b/src/dune @@ -1,8 +1,12 @@ (library - (name tiny_httpd) - (public_name tiny_httpd) - (flags :standard -open Tiny_httpd_core) - (libraries threads seq unix hmap - (re_export tiny_httpd.core) - (re_export tiny_httpd.html) - (re_export tiny_httpd.unix))) + (name tiny_httpd) + (public_name tiny_httpd) + (flags :standard -open Tiny_httpd_core) + (libraries + threads + seq + unix + hmap + (re_export tiny_httpd.core) + (re_export tiny_httpd.html) + (re_export tiny_httpd.unix))) diff --git a/src/html/dune b/src/html/dune index 64386122..a9cc3c54 100644 --- a/src/html/dune +++ b/src/html/dune @@ -1,10 +1,8 @@ - - (library - (name tiny_httpd_html) - (public_name tiny_httpd.html) - (flags :standard -open Tiny_httpd_core) - (libraries seq tiny_httpd.core)) + (name tiny_httpd_html) + (public_name tiny_httpd.html) + (flags :standard -open Tiny_httpd_core) + (libraries seq tiny_httpd.core)) (rule (targets html_.ml) diff --git a/src/prometheus/dune b/src/prometheus/dune index 40b01150..3fe37662 100644 --- a/src/prometheus/dune +++ b/src/prometheus/dune @@ -1,5 +1,3 @@ - - (library (name tiny_httpd_prometheus) (public_name tiny_httpd.prometheus) @@ -7,7 +5,10 @@ (private_modules common_p_ time_) (flags :standard -open Tiny_httpd_core) (libraries - (re_export tiny_httpd.core) unix - (select time_.ml from + (re_export tiny_httpd.core) + unix + (select + time_.ml + from (mtime mtime.clock.os -> time_.mtime.ml) (-> time_.default.ml)))) diff --git a/src/unix/dune b/src/unix/dune index b10ee59e..b741ead1 100644 --- a/src/unix/dune +++ b/src/unix/dune @@ -1,12 +1,15 @@ - (library - (name tiny_httpd_unix) - (public_name tiny_httpd.unix) - (synopsis "Backend based on Unix and blocking IOs for Tiny_httpd") - (flags :standard -open Tiny_httpd_core) - (private_modules mime_) - (libraries tiny_httpd.core tiny_httpd.html unix - (select mime_.ml from - (magic-mime -> mime_.magic.ml) - ( -> mime_.dummy.ml)) - )) + (name tiny_httpd_unix) + (public_name tiny_httpd.unix) + (synopsis "Backend based on Unix and blocking IOs for Tiny_httpd") + (flags :standard -open Tiny_httpd_core) + (private_modules mime_) + (libraries + tiny_httpd.core + tiny_httpd.html + unix + (select + mime_.ml + from + (magic-mime -> mime_.magic.ml) + (-> mime_.dummy.ml)))) diff --git a/src/unix/mime_.mli b/src/unix/mime_.mli index 1831c02d..ba78cf2c 100644 --- a/src/unix/mime_.mli +++ b/src/unix/mime_.mli @@ -1,2 +1 @@ - -val mime_of_path : string -> string +val mime_of_path : string -> string diff --git a/src/unix/tiny_httpd_unix.ml b/src/unix/tiny_httpd_unix.ml index d3e01ef3..21ec2dff 100644 --- a/src/unix/tiny_httpd_unix.ml +++ b/src/unix/tiny_httpd_unix.ml @@ -31,7 +31,7 @@ module Unix_tcp_server_ = struct { IO.TCP_server.serve = (fun ~after_init ~handle () : unit -> - if self.masksigpipe && not (Sys.win32) then + if self.masksigpipe && not Sys.win32 then ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list); let sock, should_bind = match self.sock with @@ -83,7 +83,7 @@ module Unix_tcp_server_ = struct (Thread.id @@ Thread.self ()) (Util.show_sockaddr client_addr)); - if self.masksigpipe && not (Sys.win32) then + if self.masksigpipe && not Sys.win32 then ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list); Unix.set_nonblock client_sock; Unix.setsockopt client_sock Unix.TCP_NODELAY true; @@ -113,7 +113,7 @@ module Unix_tcp_server_ = struct Sem.acquire 1 self.sem_max_connections; (* Block INT/HUP while cloning to avoid children handling them. When thread gets them, our Unix.accept raises neatly. *) - if not (Sys.win32) then + if not Sys.win32 then ignore Unix.(sigprocmask SIG_BLOCK Sys.[ sigint; sighup ]); self.new_thread (fun () -> try @@ -137,7 +137,7 @@ module Unix_tcp_server_ = struct (Util.show_sockaddr client_addr) (Printexc.to_string e) (Printexc.raw_backtrace_to_string bt))); - if not (Sys.win32) then + if not Sys.win32 then ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ]) | exception Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _) -> diff --git a/src/ws/dune b/src/ws/dune index 55fe9be9..19203d2f 100644 --- a/src/ws/dune +++ b/src/ws/dune @@ -1,12 +1,13 @@ - (library - (name tiny_httpd_ws) - (public_name tiny_httpd.ws) - (synopsis "Websockets for tiny_httpd") - (private_modules common_ws_ utils_) - (flags :standard -open Tiny_httpd_core) - (foreign_stubs - (language c) - (names tiny_httpd_ws_stubs) - (flags :standard -std=c99 -fPIC -O2)) - (libraries (re_export tiny_httpd.core) threads)) + (name tiny_httpd_ws) + (public_name tiny_httpd.ws) + (synopsis "Websockets for tiny_httpd") + (private_modules common_ws_ utils_) + (flags :standard -open Tiny_httpd_core) + (foreign_stubs + (language c) + (names tiny_httpd_ws_stubs) + (flags :standard -std=c99 -fPIC -O2)) + (libraries + (re_export tiny_httpd.core) + threads)) diff --git a/tests/prometheus/dune b/tests/prometheus/dune index da921019..6cb28c1a 100644 --- a/tests/prometheus/dune +++ b/tests/prometheus/dune @@ -1,4 +1,3 @@ - (test - (name t_prom) - (libraries tiny_httpd.prometheus)) + (name t_prom) + (libraries tiny_httpd.prometheus)) diff --git a/tests/unit/dune b/tests/unit/dune index b4ceef08..4aa1fc95 100644 --- a/tests/unit/dune +++ b/tests/unit/dune @@ -1,5 +1,4 @@ - (tests - (names t_util t_buf t_server t_io) - (package tiny_httpd) - (libraries tiny_httpd.core qcheck-core qcheck-core.runner test_util)) + (names t_util t_buf t_server t_io) + (package tiny_httpd) + (libraries tiny_httpd.core qcheck-core qcheck-core.runner test_util)) diff --git a/tests/unit/util/dune b/tests/unit/util/dune index e2790663..d59f58bd 100644 --- a/tests/unit/util/dune +++ b/tests/unit/util/dune @@ -1,5 +1,4 @@ - (library - (name test_util) - (modules test_util) - (libraries logs qcheck-core qcheck-core.runner)) + (name test_util) + (modules test_util) + (libraries logs qcheck-core qcheck-core.runner)) diff --git a/tests/unit/ws/dune b/tests/unit/ws/dune index e190baf5..3b9de796 100644 --- a/tests/unit/ws/dune +++ b/tests/unit/ws/dune @@ -1,6 +1,5 @@ - (tests - (names t_ws t_ws_q) - (package tiny_httpd) - (deps masked.data) - (libraries tiny_httpd.ws qcheck-core qcheck-core.runner test_util)) + (names t_ws t_ws_q) + (package tiny_httpd) + (deps masked.data) + (libraries tiny_httpd.ws qcheck-core qcheck-core.runner test_util))