mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
moved back acquire before accept but inside the try ... with ... one never knowns
This commit is contained in:
parent
97eeaf96dc
commit
c3265af08f
1 changed files with 3 additions and 2 deletions
|
|
@ -724,7 +724,8 @@ module Sem_ = struct
|
||||||
Condition.broadcast t.cond;
|
Condition.broadcast t.cond;
|
||||||
Mutex.unlock t.mutex
|
Mutex.unlock t.mutex
|
||||||
|
|
||||||
let available_connections t = t.n
|
(* +1 because we decrease the semaphore before Unix.accept *)
|
||||||
|
let available_connections t = t.n + 1
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1123,8 +1124,8 @@ let run (self:t) : (unit,_) result =
|
||||||
while self.running do
|
while self.running do
|
||||||
(* limit concurrency *)
|
(* limit concurrency *)
|
||||||
try
|
try
|
||||||
let client_sock, _ = Unix.accept sock in
|
|
||||||
Sem_.acquire 1 self.sem_max_connections;
|
Sem_.acquire 1 self.sem_max_connections;
|
||||||
|
let client_sock, _ = Unix.accept sock in
|
||||||
self.new_thread
|
self.new_thread
|
||||||
(fun () ->
|
(fun () ->
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue