mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-10 21:24:03 -05:00
Merge pull request #22 from craff/master
Unix.accept may raise an exception
This commit is contained in:
commit
ac05b9eaa1
1 changed files with 16 additions and 11 deletions
|
|
@ -1088,6 +1088,7 @@ let run (self:t) : (unit,_) result =
|
||||||
while self.running do
|
while self.running do
|
||||||
(* limit concurrency *)
|
(* limit concurrency *)
|
||||||
Sem_.acquire 1 self.sem_max_connections;
|
Sem_.acquire 1 self.sem_max_connections;
|
||||||
|
try
|
||||||
let client_sock, _ = Unix.accept sock in
|
let client_sock, _ = Unix.accept sock in
|
||||||
self.new_thread
|
self.new_thread
|
||||||
(fun () ->
|
(fun () ->
|
||||||
|
|
@ -1099,6 +1100,10 @@ let run (self:t) : (unit,_) result =
|
||||||
Sem_.release 1 self.sem_max_connections;
|
Sem_.release 1 self.sem_max_connections;
|
||||||
raise e
|
raise e
|
||||||
);
|
);
|
||||||
|
with e ->
|
||||||
|
_debug (fun k -> k
|
||||||
|
"Unix.accept or Thread.create raised an exception: %s"
|
||||||
|
(Printexc.to_string e))
|
||||||
done;
|
done;
|
||||||
Ok ()
|
Ok ()
|
||||||
with e -> Error e
|
with e -> Error e
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue