Changeset 6473 in project


Ignore:
Timestamp:
10/21/07 12:37:08 (13 years ago)
Author:
certainty
Message:
 
Location:
sendfile
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sendfile/branches/thread_test/tests/test-run.scm

    r5531 r6473  
    1616(flush-output)
    1717(sleep 4)
     18
     19
     20     
     21
    1822
    1923(test-group "read-write-loop"
  • sendfile/trunk/sendfile.scm

    r6388 r6473  
    108108
    109109
    110 (define (sendfile:mmaped src dst len)
    111   (let ((mapped (map-file-to-memory #f len prot/read (botwise-ior map/shared map/file) src 0))
    112         (ptr+ (lambda (ptr offset)
    113                 (address->pointer (+ (pointer->address ptr) offset))))
    114         (copy-ptr (lambda (ptr) (ptr+ ptr 0))))
    115     (%madvise-sequential% machine-ptr len)
    116     (let loop ((tosend len) (machine-ptr (copy-ptr (memory-mapped-file-pointer mmaped))))
     110(define (sendfile:mmapped src dst len)
     111  (let* ((mapped (map-file-to-memory #f len prot/read (bitwise-ior map/shared map/file) src 0))
     112         (copy-ptr (lambda (ptr) (pointer-offset ptr 0)))
     113         (machine-ptr (copy-ptr (memory-mapped-file-pointer mapped))))
     114    ;(%madvise-sequential% machine-ptr len)
     115    (let loop ((tosend len) (machine-ptr machine-ptr))
    117116      (let ((res (##core#inline "C_write" dst machine-ptr tosend))
    118117            (errno (##sys#update-errno)))
    119118        (cond
    120          ((and (negative? res) (not (= errno errno/eagain)))
     119         ((and (negative? res) (not (= errno errno/again)))
    121120          (sendfile:error "mmapped failed"))
    122121         ((not (positive? tosend))
    123           (unmap-file-from-memory mmaped len)
    124           len)
     122          (unmap-file-from-memory mapped len) len)
    125123         (else
    126           (loop (- tosend res) (ptr+ machine-ptr res))))))))
     124          (loop (- tosend res) (pointer-offset machine-ptr res))))))))
    127125   
    128126   
     
    132130;;if write fails it checks if errno is set to EAGAIN
    133131;;all other behavior is preserved
     132
     133;;WE CAN NOT USE C_WRITE to write the buffer
     134;;#define C_write(fd, b, n)   C_fix(write(C_unfix(fd), C_data_pointer(b), C_unfix(n)))
     135;;#define C_data_pointer(x)          ((void *)((C_SCHEME_BLOCK *)(x))->data)
    134136(define (sendfile:file-write fd buffer . size)
    135137  (##sys#check-exact fd 'file-write)
  • sendfile/trunk/tests/test-run.scm

    r5531 r6473  
    4343
    4444
    45 (if sendfile:os-dep:sendfile-available?
    46     (test-group "sendfile-impl"
    47                 (test "send"
    48                       test-file-size
    49                       (with-prepared-environment
    50                        (lambda (in out)
    51                          (sendfile:sendfile-impl in out test-file-size))))
    52                  (sleep 1)
    53                  (test "verify"
    54                        test-file-checksum
    55                        (compute-file-checksum test-file-out))))
     45;; (if sendfile:os-dep:sendfile-available?
     46;;     (test-group "sendfile-impl"
     47;;                 (test "send"
     48;;                       test-file-size
     49;;                       (with-prepared-environment
     50;;                        (lambda (in out)
     51;;                          (sendfile:sendfile-impl in out test-file-size))))
     52;;                  (sleep 1)
     53;;                  (test "verify"
     54;;                        test-file-checksum
     55;;                        (compute-file-checksum test-file-out))))
    5656
    57 (test-begin "interface")
     57;; (test-begin "interface")
    5858
    59 (test "sendfile"
    60       test-file-size
    61       (with-prepared-environment
    62        (lambda (in out)
    63          (sendfile:sendfile in out test-file-size))))
     59;; (test "sendfile"
     60;;       test-file-size
     61;;       (with-prepared-environment
     62;;        (lambda (in out)
     63;;          (sendfile:sendfile in out test-file-size))))
    6464
    65 (test "force read-write"
    66       (list 'read-write test-file-size)
    67       (with-prepared-environment
    68        (lambda (in out)
    69          (sendfile:sendfile in out test-file-size 'read-write #t))))
     65;; (test "force read-write"
     66;;       (list 'read-write test-file-size)
     67;;       (with-prepared-environment
     68;;        (lambda (in out)
     69;;          (sendfile:sendfile in out test-file-size 'read-write #t))))
    7070
    71 (test "force mmapped"
    72       (list 'mmapped test-file-size)
    73       (with-prepared-environment
    74        (lambda (in out)
    75          (sendfile:sendfile in out test-file-size 'mmapped #t))))
     71;; (test "force mmapped"
     72;;       (list 'mmapped test-file-size)
     73;;       (with-prepared-environment
     74;;        (lambda (in out)
     75;;          (sendfile:sendfile in out test-file-size 'mmapped #t))))
    7676
    77 (if sendfile:os-dep:sendfile-available?
    78     (test "force sendfile"
    79           (list 'sendfile test-file-size)
    80           (with-prepared-environment
    81            (lambda (in out)
    82              (sendfile:sendfile in out test-file-size 'sendfile #t)))))
     77;; (if sendfile:os-dep:sendfile-available?
     78;;     (test "force sendfile"
     79;;           (list 'sendfile test-file-size)
     80;;           (with-prepared-environment
     81;;            (lambda (in out)
     82;;              (sendfile:sendfile in out test-file-size 'sendfile #t)))))
    8383
    84 (test-end "interface")
     84;; (test-end "interface")
    8585
    8686(display "shutting down server")
Note: See TracChangeset for help on using the changeset viewer.