Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Aug 15, 2024
1 parent 0fbfd9d commit de9760d
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 74 deletions.
4 changes: 2 additions & 2 deletions src/Tiny_httpd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/camlzip/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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))
21 changes: 13 additions & 8 deletions src/core/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
18 changes: 11 additions & 7 deletions src/dune
Original file line number Diff line number Diff line change
@@ -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)))
10 changes: 4 additions & 6 deletions src/html/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 5 additions & 4 deletions src/prometheus/dune
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@


(library
(name tiny_httpd_prometheus)
(public_name tiny_httpd.prometheus)
(synopsis "Metrics using prometheus")
(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))))
25 changes: 14 additions & 11 deletions src/unix/dune
Original file line number Diff line number Diff line change
@@ -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))))
3 changes: 1 addition & 2 deletions src/unix/mime_.mli
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

val mime_of_path : string -> string
val mime_of_path : string -> string
8 changes: 4 additions & 4 deletions src/unix/tiny_httpd_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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), _, _)
->
Expand Down
23 changes: 12 additions & 11 deletions src/ws/dune
Original file line number Diff line number Diff line change
@@ -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))
5 changes: 2 additions & 3 deletions tests/prometheus/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

(test
(name t_prom)
(libraries tiny_httpd.prometheus))
(name t_prom)
(libraries tiny_httpd.prometheus))
7 changes: 3 additions & 4 deletions tests/unit/dune
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 3 additions & 4 deletions tests/unit/util/dune
Original file line number Diff line number Diff line change
@@ -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))
9 changes: 4 additions & 5 deletions tests/unit/ws/dune
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit de9760d

Please sign in to comment.