diff --git a/src/Tiny_httpd.ml b/src/Tiny_httpd.ml index 80380f9e..751ee0ca 100644 --- a/src/Tiny_httpd.ml +++ b/src/Tiny_httpd.ml @@ -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; diff --git a/src/examples/dune b/src/examples/dune index b7cfcbf7..7a1eef1e 100644 --- a/src/examples/dune +++ b/src/examples/dune @@ -1,4 +1,4 @@ (executables (names echo) - (libraries tiny_httpd)) + (libraries tiny_httpd statmemprof-notty)) diff --git a/src/examples/echo.ml b/src/examples/echo.ml index 50ab8356..0a673e74 100644 --- a/src/examples/echo.ml +++ b/src/examples/echo.ml @@ -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