Add exception handling to the server loop
This should start to deal with accept failing if there are too many open files.
This commit is contained in:
parent
768c2b6a5b
commit
bb6d9fd89d
1 changed files with 22 additions and 13 deletions
|
|
@ -576,19 +576,28 @@ before sending back to the client."
|
||||||
|
|
||||||
(spawn-fiber
|
(spawn-fiber
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let loop ()
|
(while #t
|
||||||
(match (accept socket (logior SOCK_NONBLOCK SOCK_CLOEXEC))
|
(with-exception-handler
|
||||||
((client . sockaddr)
|
(const #t)
|
||||||
(spawn-fiber (lambda ()
|
(lambda ()
|
||||||
(client-loop client handler
|
(with-exception-handler
|
||||||
read-request-exception-handler
|
(lambda (exn)
|
||||||
write-response-exception-handler
|
(print-backtrace-and-exception/knots exn))
|
||||||
connection-idle-timeout
|
(lambda ()
|
||||||
connection-buffer-size
|
(let loop ()
|
||||||
(post-request-hook/safe
|
(match (accept socket (logior SOCK_NONBLOCK SOCK_CLOEXEC))
|
||||||
post-request-hook)))
|
((client . sockaddr)
|
||||||
#:parallel? #t)
|
(spawn-fiber (lambda ()
|
||||||
(loop))))))
|
(client-loop client handler
|
||||||
|
read-request-exception-handler
|
||||||
|
write-response-exception-handler
|
||||||
|
connection-idle-timeout
|
||||||
|
connection-buffer-size
|
||||||
|
(post-request-hook/safe
|
||||||
|
post-request-hook)))
|
||||||
|
#:parallel? #t)
|
||||||
|
(loop)))))))
|
||||||
|
#:unwind? #t))))
|
||||||
|
|
||||||
(make-web-server socket
|
(make-web-server socket
|
||||||
(vector-ref (getsockname socket)
|
(vector-ref (getsockname socket)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue