http-read robustness
authorAndy Wingo <wingo@pobox.com>
Sun, 12 Dec 2010 20:59:29 +0000 (21:59 +0100)
committerAndy Wingo <wingo@pobox.com>
Sun, 12 Dec 2010 20:59:29 +0000 (21:59 +0100)
* module/web/server/http.scm (http-read): Record the client index in
  more cases in which code could throw an error.

module/web/server/http.scm

index 0cbf43b..e9d612b 100644 (file)
@@ -84,6 +84,7 @@
             (lp (1- (poll-set-nfds poll-set))))
            ((not (zero? (logand revents *error-events*)))
             ;; An error.
+            (set-http-poll-idx! server idx)
             (throw 'interrupt))
            (else
             ;; A new client. Add to set, poll, and loop.
          ;; it. Remove it from the poll set.
          (else
           (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
              ((eof-object? (peek-char port))
               ;; EOF.
               (lp (1- idx)))
              (else
               ;; Otherwise, try to read a request from this port.
-              ;; Record the next index.
-              (set-http-poll-idx! server (1- idx))
               (with-throw-handler
                #t
                (lambda ()