mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-08 12:15:41 -05:00
perf: only call select in accept loop if accept would have blocked
This commit is contained in:
parent
217defecc5
commit
20a36919ce
1 changed files with 2 additions and 2 deletions
|
|
@ -984,7 +984,6 @@ module Unix_tcp_server_ = struct
|
||||||
|
|
||||||
Unix.set_nonblock sock;
|
Unix.set_nonblock sock;
|
||||||
while self.running do
|
while self.running do
|
||||||
ignore (Unix.select [ sock ] [] [ sock ] 1.0 : _ * _ * _);
|
|
||||||
match Unix.accept sock with
|
match Unix.accept sock with
|
||||||
| client_sock, client_addr ->
|
| client_sock, client_addr ->
|
||||||
(* limit concurrency *)
|
(* limit concurrency *)
|
||||||
|
|
@ -1012,7 +1011,8 @@ module Unix_tcp_server_ = struct
|
||||||
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
||||||
| exception Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _)
|
| exception Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _)
|
||||||
->
|
->
|
||||||
()
|
(* wait for the socket to be ready, and re-enter the loop *)
|
||||||
|
ignore (Unix.select [ sock ] [] [ sock ] 1.0 : _ * _ * _)
|
||||||
| exception e ->
|
| exception e ->
|
||||||
Log.error (fun k ->
|
Log.error (fun k ->
|
||||||
k "Unix.accept or Thread.create raised an exception: %s"
|
k "Unix.accept or Thread.create raised an exception: %s"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue