summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Andy Wingo2010-12-06 11:37:47 +0100
committerGravatar Andy Wingo2010-12-06 11:37:47 +0100
commit15f024a12d214df681b83967894f7d7244013514 (patch)
treee3edd1a14abbf30e414ddd10ce7215278f978560
parentfc386dcb71d3691e19a08ac623e4ec4e9e97c4dc (diff)
downloadtekuti-15f024a12d214df681b83967894f7d7244013514.tar.gz
tekuti-15f024a12d214df681b83967894f7d7244013514.zip
robustness in mod-lisp-read
* tekuti/mod-lisp.scm (mod-lisp-read): Close the port if there is an error reading the request.
-rw-r--r--tekuti/mod-lisp.scm17
1 files changed, 11 insertions, 6 deletions
diff --git a/tekuti/mod-lisp.scm b/tekuti/mod-lisp.scm
index bb35e10..b16dab7 100644
--- a/tekuti/mod-lisp.scm
+++ b/tekuti/mod-lisp.scm
@@ -242,12 +242,17 @@
;; Otherwise, try to read a request from this port.
;; Record the next index.
(set-mod-lisp-poll-idx! server (1- idx))
- (let ((req (read-request/mod-lisp port)))
- ;; Block buffering for reading body and writing response.
- (setvbuf port _IOFBF)
- (values port
- req
- (read-request-body/latin-1 req))))))))))))
+ (with-throw-handler
+ #t
+ (lambda ()
+ (let ((req (read-request/mod-lisp port)))
+ ;; Block buffering for reading body and writing response.
+ (setvbuf port _IOFBF)
+ (values port
+ req
+ (read-request-body/latin-1 req))))
+ (lambda (k . args)
+ (false-if-exception (close-port port)))))))))))))
;; -> unspecified values
(define (mod-lisp-write server client response body)