mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
parent
bc34363f60
commit
14a48756a8
4 changed files with 12 additions and 6 deletions
|
|
@ -1,3 +1,6 @@
|
|||
## Pending
|
||||
|
||||
- fix: No setting of sigprocmask on Windows
|
||||
|
||||
## 0.16
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ open struct
|
|||
slice.len <- 0
|
||||
end
|
||||
|
||||
let create ?(masksigpipe = true) ?max_connections ?(timeout = 0.0) ?buf_size
|
||||
let create ?(masksigpipe = not (Sys.win32)) ?max_connections ?(timeout = 0.0) ?buf_size
|
||||
?(get_time_s = Unix.gettimeofday)
|
||||
?(new_thread = fun f -> ignore (Thread.create f () : Thread.t))
|
||||
?(addr = "127.0.0.1") ?(port = 8080) ?sock ?middlewares () : t =
|
||||
|
|
|
|||
|
|
@ -144,7 +144,8 @@ val create :
|
|||
{!set_top_handler} to specify how to handle incoming requests.
|
||||
|
||||
@param masksigpipe if true, block the signal {!Sys.sigpipe} which otherwise
|
||||
tends to kill client threads when they try to write on broken sockets. Default: [true].
|
||||
tends to kill client threads when they try to write on broken sockets.
|
||||
Default: [true] except when on Windows, which defaults to [false].
|
||||
|
||||
@param buf_size size for buffers (since 0.11)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ module Unix_tcp_server_ = struct
|
|||
{
|
||||
IO.TCP_server.serve =
|
||||
(fun ~after_init ~handle () : unit ->
|
||||
if self.masksigpipe then
|
||||
if self.masksigpipe && not (Sys.win32) then
|
||||
ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list);
|
||||
let sock, should_bind =
|
||||
match self.sock with
|
||||
|
|
@ -83,7 +83,7 @@ module Unix_tcp_server_ = struct
|
|||
(Thread.id @@ Thread.self ())
|
||||
(Util.show_sockaddr client_addr));
|
||||
|
||||
if self.masksigpipe then
|
||||
if self.masksigpipe && not (Sys.win32) then
|
||||
ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list);
|
||||
Unix.set_nonblock client_sock;
|
||||
Unix.setsockopt client_sock Unix.TCP_NODELAY true;
|
||||
|
|
@ -113,7 +113,8 @@ module Unix_tcp_server_ = struct
|
|||
Sem.acquire 1 self.sem_max_connections;
|
||||
(* Block INT/HUP while cloning to avoid children handling them.
|
||||
When thread gets them, our Unix.accept raises neatly. *)
|
||||
ignore Unix.(sigprocmask SIG_BLOCK Sys.[ sigint; sighup ]);
|
||||
if not (Sys.win32) then
|
||||
ignore Unix.(sigprocmask SIG_BLOCK Sys.[ sigint; sighup ]);
|
||||
self.new_thread (fun () ->
|
||||
try
|
||||
handle_client_unix_ client_sock client_addr;
|
||||
|
|
@ -136,7 +137,8 @@ module Unix_tcp_server_ = struct
|
|||
(Util.show_sockaddr client_addr)
|
||||
(Printexc.to_string e)
|
||||
(Printexc.raw_backtrace_to_string bt)));
|
||||
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
||||
if not (Sys.win32) then
|
||||
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
||||
| exception Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _)
|
||||
->
|
||||
(* wait for the socket to be ready, and re-enter the loop *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue