Commit 56fab69d958b5f0229557741d393da05c4f16099

Thomas de Grivel 2018-06-09T18:54:16

continue

diff --git a/thot.lisp b/thot.lisp
index 933d4b2..9942ac4 100644
--- a/thot.lisp
+++ b/thot.lisp
@@ -507,25 +507,32 @@ The requested url "
   (let ((handlers *url-handlers*)
         (*request* request)
         (*reply* reply))
-    (handler-bind
-        ((errno:errno-error (lambda (condition)
-                              (cond ((= errno:+epipe+
-                                        (errno:errno-error-errno condition))
-                                     (format t "~&~S~%" condition)
-                                     (return-from request-cont))))))
-      (loop
-         (let ((handler-form (pop handlers)))
-           (let ((handler (call-handler-form handler-form)))
-             (when (debug-p :thot)
-               (format t "~&~S -> ~S~%" handler-form handler)
-               (force-output))
-             (when handler
-               (call-handler handler)
-               (stream-flush (reply-stream% reply))
-               (return)))))
-      (if (string-equal "keep-alive" (request-header 'connection))
-          :keep-alive
-          nil))))
+    (with-simple-restart (continue "Continue")
+      (handler-bind
+          ((cffi-errno:errno-error
+            (lambda (condition)
+              (let ((errno (the fixnum
+                                (errno:errno-error-errno condition))))
+                (when (find errno '(errno:+epipe+
+                                    errno:+econnreset+))
+                  (when (debug-p :thot)
+                    (format t "err ~&~A~%" condition)
+                    (force-output))
+                  (return-from request-cont))))))
+        (loop
+           (let ((handler-form (pop handlers)))
+             (unless handler-form (return))
+             (let ((handler (call-handler-form handler-form)))
+               (when (debug-p :thot)
+                 (format t "~&~S -> ~S~%" handler-form handler)
+                 (force-output))
+               (when handler
+                 (call-handler handler)
+                 (stream-flush (reply-stream% reply))
+                 (return)))))
+        (if (string-equal "keep-alive" (request-header 'connection))
+            :keep-alive
+            nil)))))
 
 (defvar *stop* nil)