mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
wip: use statmemprof-notty
This commit is contained in:
parent
3f0e427bbf
commit
64e232e459
3 changed files with 6 additions and 8 deletions
|
|
@ -775,13 +775,6 @@ let run (self:t) : (unit,_) result =
|
|||
let inet_addr = Unix.inet_addr_of_string self.addr in
|
||||
Unix.bind sock (Unix.ADDR_INET (inet_addr, self.port));
|
||||
Unix.listen sock (self.sem_max_connections.Sem_.n);
|
||||
|
||||
ignore @@ Thread.create (fun () ->
|
||||
while true do
|
||||
_debug (fun k->k "sem: %d" self.sem_max_connections.n);
|
||||
Unix.sleep 1;
|
||||
done) ();
|
||||
|
||||
while self.running do
|
||||
(* limit concurrency *)
|
||||
Sem_.acquire self.sem_max_connections;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
(executables
|
||||
(names echo)
|
||||
(libraries tiny_httpd))
|
||||
(libraries tiny_httpd statmemprof-notty))
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ let () =
|
|||
"/echo" (fun req -> S.Response.make_string (Ok (Format.asprintf "echo:@ %a@." S.Request.pp req)));
|
||||
S.add_path_handler ~meth:`POST server
|
||||
"/debug/%B" (fun b _req -> S._enable_debug b; S.Response.make_string (Ok "ok"));
|
||||
S.add_path_handler ~meth:`POST server
|
||||
"/compact/" (fun _req -> Gc.compact(); S.Response.make_string (Ok "gc.compact: done"));
|
||||
S.add_path_handler ~meth:`POST server
|
||||
"/quit/" (fun _req -> S.stop server; S.Response.make_string (Ok "bye"));
|
||||
S.add_path_handler ~meth:`PUT server
|
||||
"/upload/%s" (fun path req ->
|
||||
S._debug (fun k->k "start upload %S\n%!" path);
|
||||
|
|
@ -31,6 +35,7 @@ let () =
|
|||
S.Response.fail ~code:500 "couldn't upload file: %s" (Printexc.to_string e)
|
||||
);
|
||||
Printf.printf "listening on http://%s:%d\n%!" (S.addr server) (S.port server);
|
||||
ignore @@ Thread.create (fun () -> Statmemprof_inuit.start 1e-4 300 2) ();
|
||||
match S.run server with
|
||||
| Ok () -> ()
|
||||
| Error e -> raise e
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue