mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
put back active_connections
This commit is contained in:
parent
b539b4f9ba
commit
10b64c2a16
2 changed files with 9 additions and 1 deletions
|
|
@ -676,13 +676,14 @@ end
|
|||
module Sem_ = struct
|
||||
type t = {
|
||||
mutable n : int;
|
||||
max : int;
|
||||
mutex : Mutex.t;
|
||||
cond : Condition.t;
|
||||
}
|
||||
|
||||
let create n =
|
||||
if n <= 0 then invalid_arg "Semaphore.create";
|
||||
{ n; mutex=Mutex.create(); cond=Condition.create(); }
|
||||
{ n; max=n; mutex=Mutex.create(); cond=Condition.create(); }
|
||||
|
||||
let acquire m t =
|
||||
Mutex.lock t.mutex;
|
||||
|
|
@ -699,6 +700,8 @@ module Sem_ = struct
|
|||
t.n <- t.n + m;
|
||||
Condition.broadcast t.cond;
|
||||
Mutex.unlock t.mutex
|
||||
|
||||
let num_acquired t = t.max - t.n
|
||||
end
|
||||
|
||||
module Route = struct
|
||||
|
|
@ -843,6 +846,8 @@ type t = {
|
|||
let addr self = self.addr
|
||||
let port self = self.port
|
||||
|
||||
let active_connections self = Sem_.num_acquired self.sem_max_connections - 1
|
||||
|
||||
let add_decode_request_cb self f = self.cb_decode_req <- f :: self.cb_decode_req
|
||||
let add_encode_response_cb self f = self.cb_encode_resp <- f :: self.cb_encode_resp
|
||||
let set_top_handler self f = self.handler <- f
|
||||
|
|
|
|||
|
|
@ -476,6 +476,9 @@ val is_ipv6 : t -> bool
|
|||
val port : t -> int
|
||||
(** Port on which the server listens. *)
|
||||
|
||||
val active_connections : t -> int
|
||||
(** Number of active connections *)
|
||||
|
||||
val add_decode_request_cb :
|
||||
t ->
|
||||
(unit Request.t -> (unit Request.t * (byte_stream -> byte_stream)) option) -> unit
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue