Commit 091716dfa9e4e097fdb4c7df906eb080c5040040

Thomas de Grivel 2017-06-28T02:35:48

handle EPIPE

diff --git a/thot.lisp b/thot.lisp
index 80c1c67..119baf2 100644
--- a/thot.lisp
+++ b/thot.lisp
@@ -285,17 +285,22 @@ The requested url ~S was not found on this server."
   (let ((handlers *url-handlers*)
         (*request* request)
         (*reply* reply))
-    (loop
-       (when (endp handlers)
-         (return))
-       (let* ((handler-func (pop handlers))
-              (handler (funcall handler-func)))
-         (when handler
-           (when (debug-p (or :thot :http))
-             (format t "~&~S -> ~S~%" handler-func handler))
-           (funcall handler)
-           (flush (reply-stream% reply))
-           (return))))
+    (handler-bind
+        ((errno:errno-error (lambda (condition)
+                              (cond ((= errno:+epipe+
+                                        (errno:errno-error-errno condition))
+                                     (return-from request-cont))))))
+      (loop
+         (when (endp handlers)
+           (return))
+         (let* ((handler-func (pop handlers))
+                (handler (funcall handler-func)))
+           (when handler
+             (when (debug-p (or :thot :http))
+               (format t "~&~S -> ~S~%" handler-func handler))
+             (funcall handler)
+             (flush (reply-stream% reply))
+             (return)))))
     (if (string-equal "keep-alive" (request-header 'connection))
         :keep-alive
         nil)))