From b500ced6b8562112a28d2015bf9af1e808caa9bf Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 6 Dec 2010 11:24:48 +0100 Subject: [PATCH] more robustness in http-read * module/web/server/http.scm (http-read): If there was an error reading the request, be sure to close the request port. --- module/web/server/http.scm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/module/web/server/http.scm b/module/web/server/http.scm index 1eefc0a77..bddbafa1f 100644 --- a/module/web/server/http.scm +++ b/module/web/server/http.scm @@ -113,12 +113,17 @@ ;; Otherwise, try to read a request from this port. ;; Record the next index. (set-http-poll-idx! server (1- idx)) - (let ((req (read-request port))) - ;; Block buffering for reading body and writing response. - (setvbuf port _IOFBF) - (values port - req - (read-request-body/bytevector req)))))))))))) + (with-throw-handler + #t + (lambda () + (let ((req (read-request port))) + ;; Block buffering for reading body and writing response. + (setvbuf port _IOFBF) + (values port + req + (read-request-body/bytevector req)))) + (lambda (k . args) + (false-if-exception (close-port port))))))))))))) (define (keep-alive? response) (let ((v (response-version response)))