File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -937,11 +937,14 @@ module Unix_tcp_server_ = struct
937937 ()
938938 in
939939
940+ Unix. set_nonblock sock;
940941 while self.running do
941- (* limit concurrency *)
942- Sem_. acquire 1 self.sem_max_connections;
943- try
944- let client_sock, client_addr = Unix. accept sock in
942+ ignore (Unix. select [ sock ] [] [ sock ] 1.0 : _ * _ * _ );
943+ match Unix. accept sock with
944+ | client_sock , client_addr ->
945+ (* limit concurrency *)
946+ Sem_. acquire 1 self.sem_max_connections;
947+
945948 Unix. setsockopt client_sock Unix. TCP_NODELAY true ;
946949 (* Block INT/HUP while cloning to avoid children handling them.
947950 When thread gets them, our Unix.accept raises neatly. *)
@@ -955,8 +958,10 @@ module Unix_tcp_server_ = struct
955958 Sem_. release 1 self.sem_max_connections;
956959 raise e);
957960 ignore Unix. (sigprocmask SIG_UNBLOCK Sys. [ sigint; sighup ])
958- with e ->
959- Sem_. release 1 self.sem_max_connections;
961+ | exception Unix .Unix_error ((Unix. EAGAIN | Unix. EWOULDBLOCK ), _, _)
962+ ->
963+ ()
964+ | exception e ->
960965 _debug (fun k ->
961966 k " Unix.accept or Thread.create raised an exception: %s"
962967 (Printexc. to_string e))
You can’t perform that action at this time.
0 commit comments