1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

http-read robustness

* module/web/server/http.scm (http-read): Record the client index in
  more cases in which code could throw an error.
This commit is contained in:
Andy Wingo 2010-12-12 21:59:29 +01:00
parent c7857da63a
commit ec3c7570d8

View file

@ -84,6 +84,7 @@
(lp (1- (poll-set-nfds poll-set)))) (lp (1- (poll-set-nfds poll-set))))
((not (zero? (logand revents *error-events*))) ((not (zero? (logand revents *error-events*)))
;; An error. ;; An error.
(set-http-poll-idx! server idx)
(throw 'interrupt)) (throw 'interrupt))
(else (else
;; A new client. Add to set, poll, and loop. ;; A new client. Add to set, poll, and loop.
@ -104,6 +105,9 @@
;; it. Remove it from the poll set. ;; it. Remove it from the poll set.
(else (else
(let ((port (poll-set-remove! poll-set idx))) (let ((port (poll-set-remove! poll-set idx)))
;; Record the next index in all cases, in case the EOF check
;; throws an error.
(set-http-poll-idx! server (1- idx))
(cond (cond
((eof-object? (peek-char port)) ((eof-object? (peek-char port))
;; EOF. ;; EOF.
@ -111,8 +115,6 @@
(lp (1- idx))) (lp (1- idx)))
(else (else
;; Otherwise, try to read a request from this port. ;; Otherwise, try to read a request from this port.
;; Record the next index.
(set-http-poll-idx! server (1- idx))
(with-throw-handler (with-throw-handler
#t #t
(lambda () (lambda ()