Changeset 18696 in project


Ignore:
Timestamp:
07/03/10 18:45:55 (11 years ago)
Author:
sjamaan
Message:

spiffy: Get rid of a file descriptor leak. Thanks, zbigniew! :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/spiffy/trunk/spiffy.scm

    r18695 r18696  
    259259                   body: output headers: '((content-type text/html)))))
    260260
     261(define (call-with-input-file* file proc)
     262  (call-with-input-file file (lambda (p)
     263                               (handle-exceptions exn
     264                                 (begin (close-input-port p) (raise exn))
     265                                 (proc p)))))
     266
    261267(define (send-response #!key (code 200) (reason "OK") body (headers '()))
    262268  (let ((new-headers (cons `(content-length ,(if body (string-length body) 0))
     
    302308                  (write-logged-response)
    303309                  (unless (eq? 'HEAD (request-method (current-request)))
    304                     (call-with-input-file path
     310                    (call-with-input-file* path
    305311                      (lambda (f)
    306312                        (sendfile f (response-port (current-response)))))))))))
     
    338344  (let ((file (make-pathname path (access-file))))
    339345    (if (and (access-file) (file-exists? file))
    340         ((eval (call-with-input-file file read)) continue)
     346        ((eval (call-with-input-file* file read)) continue)
    341347        (continue))))
    342348
Note: See TracChangeset for help on using the changeset viewer.