mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
remove mutex to get available_connections
This commit is contained in:
parent
8da6967039
commit
9b4a1b1197
1 changed files with 4 additions and 8 deletions
|
|
@ -724,12 +724,8 @@ module Sem_ = struct
|
||||||
Condition.broadcast t.cond;
|
Condition.broadcast t.cond;
|
||||||
Mutex.unlock t.mutex
|
Mutex.unlock t.mutex
|
||||||
|
|
||||||
let available_connection t =
|
let available_connections t = t.n
|
||||||
(* locking necessary unless we have atomic read/write for int.*)
|
|
||||||
Mutex.lock t.mutex;
|
|
||||||
let r = t.n in
|
|
||||||
Mutex.unlock t.mutex;
|
|
||||||
r
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Route = struct
|
module Route = struct
|
||||||
|
|
@ -1133,14 +1129,14 @@ let run (self:t) : (unit,_) result =
|
||||||
Sem_.release 1 self.sem_max_connections;
|
Sem_.release 1 self.sem_max_connections;
|
||||||
_debug (fun k -> k
|
_debug (fun k -> k
|
||||||
"closing inactive connections (%d connections available)"
|
"closing inactive connections (%d connections available)"
|
||||||
(Sem_.available_connection self.sem_max_connections))
|
(Sem_.available_connections self.sem_max_connections))
|
||||||
with
|
with
|
||||||
| e ->
|
| e ->
|
||||||
(try Unix.close client_sock with _ -> ());
|
(try Unix.close client_sock with _ -> ());
|
||||||
Sem_.release 1 self.sem_max_connections;
|
Sem_.release 1 self.sem_max_connections;
|
||||||
_debug (fun k -> k
|
_debug (fun k -> k
|
||||||
"closing connections on error (%d connections available)"
|
"closing connections on error (%d connections available)"
|
||||||
(Sem_.available_connection self.sem_max_connections));
|
(Sem_.available_connections self.sem_max_connections));
|
||||||
raise e
|
raise e
|
||||||
);
|
);
|
||||||
with e ->
|
with e ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue