mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
release semaphore does not return anything anymore
This commit is contained in:
parent
9e9fe32347
commit
e87428ae51
1 changed files with 14 additions and 5 deletions
|
|
@ -721,8 +721,13 @@ module Sem_ = struct
|
||||||
let release m t =
|
let release m t =
|
||||||
Mutex.lock t.mutex;
|
Mutex.lock t.mutex;
|
||||||
t.n <- t.n + m;
|
t.n <- t.n + m;
|
||||||
let r = t.n in
|
|
||||||
Condition.broadcast t.cond;
|
Condition.broadcast t.cond;
|
||||||
|
Mutex.unlock t.mutex
|
||||||
|
|
||||||
|
let available_connection t =
|
||||||
|
(* locking necessary unless we have atomic read/write for int.*)
|
||||||
|
Mutex.lock t.mutex;
|
||||||
|
let r = t.n in
|
||||||
Mutex.unlock t.mutex;
|
Mutex.unlock t.mutex;
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
|
|
@ -1125,13 +1130,17 @@ let run (self:t) : (unit,_) result =
|
||||||
(fun () ->
|
(fun () ->
|
||||||
try
|
try
|
||||||
handle_client_ self client_sock;
|
handle_client_ self client_sock;
|
||||||
let avail = Sem_.release 1 self.sem_max_connections in
|
Sem_.release 1 self.sem_max_connections;
|
||||||
_debug (fun k -> k"closing inactive connections (%d connections available)" avail)
|
_debug (fun k -> k
|
||||||
|
"closing inactive connections (%d connections available)"
|
||||||
|
(Sem_.available_connection self.sem_max_connections))
|
||||||
with
|
with
|
||||||
| e ->
|
| e ->
|
||||||
(try Unix.close client_sock with _ -> ());
|
(try Unix.close client_sock with _ -> ());
|
||||||
let avail = Sem_.release 1 self.sem_max_connections in
|
Sem_.release 1 self.sem_max_connections;
|
||||||
_debug (fun k -> k"closing connections on error (%d connections available)" avail);
|
_debug (fun k -> k
|
||||||
|
"closing connections on error (%d connections available)"
|
||||||
|
(Sem_.available_connection self.sem_max_connections));
|
||||||
raise e
|
raise e
|
||||||
);
|
);
|
||||||
with e ->
|
with e ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue