Changeset 5482 in project


Ignore:
Timestamp:
08/17/07 09:25:32 (12 years ago)
Author:
certainty
Message:

the length-parameter for sendfile:sendfile is now optional
addjusted documentation
modified test-run so that it sends sigterm instead of sigint to the server.

Location:
sendfile/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sendfile/trunk/sendfile.doc.scm

    r5467 r5482  
    6565     (subsection "sending a file. the main interface"
    6666       (group           
    67         (procedure "(sendfile:sendfile source destination len [force] [debug])"
     67        (procedure "(sendfile:sendfile source destination [len] [force] [debug])"
    6868          (p "Tries to send the file identified by `source` to `destination` as fast as possible. It does this based on few factors. If no specific technique is forceed the one-argument-procedure store in the sendfile:select-implementation parameter is invoked and the size of the actual file is passed to it. This procedure returns a list of symbols that state which actual procedure shall be invoked. So if the first technique fails, the second is tried and so. So if the procedure returns '(sendfile mmapped) sendfile:sendfile will try to transmit the file using the sendfile-syscall first. If it is not available or fails, it will try to send the file using mmapped-io. If this fails as well an error is signaled. If either of them succeeds the number of bytes written is returned.")
    6969
     
    7272          (p "destination ... can be either a port to the outputfile (socket) or a filedescriptor (socketdesciptor) of an allready opened file (socket)")
    7373
    74           (p "len ... is the size of the file in bytes as e.g. retrieved by (file-size)")
     74          (p "len ... is the size of the file in bytes as e.g. retrieved by (file-size) defaults to the whole size of `source`")
    7575         
    7676          (p "force ... is a symbol stating which transmission-technique shall be used. possible values are: 'mmapped,'sendfile,'read-write,'nothing. It defaults to 'nothing")
  • sendfile/trunk/sendfile.html

    r5467 r5482  
    171171<h4>sending a file. the main interface</h4>
    172172<dl>
    173 <dt class="definition"><strong>procedure:</strong> (sendfile:sendfile source destination len [force] [debug])</dt>
     173<dt class="definition"><strong>procedure:</strong> (sendfile:sendfile source destination [len] [force] [debug])</dt>
    174174<dd>
    175175<p>Tries to send the file identified by `source` to `destination` as fast as possible. It does this based on few factors. If no specific technique is forceed the one-argument-procedure store in the sendfile:select-implementation parameter is invoked and the size of the actual file is passed to it. This procedure returns a list of symbols that state which actual procedure shall be invoked. So if the first technique fails, the second is tried and so. So if the procedure returns '(sendfile mmapped) sendfile:sendfile will try to transmit the file using the sendfile-syscall first. If it is not available or fails, it will try to send the file using mmapped-io. If this fails as well an error is signaled. If either of them succeeds the number of bytes written is returned.</p>
    176176<p>source ... can be either a port to the inputfile or a filedescriptor of an allready opened file.
    177177<p>destination ... can be either a port to the outputfile (socket) or a filedescriptor (socketdesciptor) of an allready opened file (socket)</p>
    178 <p>len ... is the size of the file in bytes as e.g. retrieved by (file-size)</p>
     178<p>len ... is the size of the file in bytes as e.g. retrieved by (file-size) defaults to the whole size of `source`</p>
    179179<p>force ... is a symbol stating which transmission-technique shall be used. possible values are: 'mmapped,'sendfile,'read-write,'nothing. It defaults to 'nothing</p>
    180180<p>debug ... is a boolean. If set to #t the procedure returns a pair on successful operation where the car holds the symbol identifiing the method used, and the cdr holds the amount of bytes sent. If it set to #f the default behavior of sendfile is preserved. Defaults to #f</p>
     
    224224<dt class="definition"><strong>parameter:</strong> sendfile:select-implementation</dt>
    225225<dd>
    226 <p>A one-argument procedure that gets the size of the file in question passed and is expected to return a list of symbols stating which transmission-method to use in what order. By default a procedure is installed that passes all file smaller than 4 * 1024 bytes to sendfile:read-write-loop. All files greater than this boundary are passed to sendfile:sendfile-impl if applicable and to sendfile:mmapped if not. The fallback-chain is is (sendfile mmapped read-write).</p></dd>
     226<p>A one-argument procedure that gets the size of the file in question passed and is expected to return a list of symbols stating which transmission-method to use in what order. By default a procedure is installed that passes all file smaller than 4 * 1024 bytes to sendfile:read-write-loop. All files greater than this boundary are passed to sendfile:sendfile-impl if applicable and to sendfile:mmapped if not. The fallback-chain is (sendfile mmapped read-write).</p></dd>
    227227<dt class="definition"><strong>parameter:</strong> sendfile:implementations</dt>
    228228<dd>
  • sendfile/trunk/sendfile.scm

    r5481 r5482  
    7171
    7272
    73 
    7473(define-foreign-variable %sendfile:have-native-sendfile int "HAVE_NATIVE_SENDFILE")
    7574
     
    166165;;main interface dispatches to the appropriate implementations
    167166;;force-options: sendfile,mmapped,read-write,nothing
    168 (define (sendfile:sendfile src dst len . opts)
     167(define (sendfile:sendfile src dst . opts)
    169168  (let ((src (sendfile:assert-port-or-filenum src))
    170169        (dst (sendfile:assert-port-or-filenum dst)))
    171     (let-optionals opts ((force 'nothing)
     170    (let-optionals opts ((len (file-size src))
     171                         (force 'nothing)
    172172                         (debug #f))
    173173                   (case force
  • sendfile/trunk/tests/server.scm

    r5480 r5482  
    11(use tcp-server posix srfi-4)
     2
     3
    24
    35(define server (make-tcp-server
     
    68                  (read-u8vector #f))))
    79
     10;;(set-signal-handler! signal/int (lambda (_) (display "server shutdown") (newline) (exit 0)))
     11
    812(server)
  • sendfile/trunk/tests/test-run.scm

    r5480 r5482  
    9090
    9191(display "shutting down server")
    92 (process-signal server-pid signal/int)
     92(process-signal server-pid)
    9393(newline)
    94 (display "sent SIGINT to server. please make sure the server isn't running anymore!")
     94(display "sent SIGTERM to server. please make sure the server isn't running anymore!")
    9595(newline)
    9696
Note: See TracChangeset for help on using the changeset viewer.