apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sascha Schumann <sas...@schumann.cx>
Subject sendfile wrapper for Linux
Date Thu, 20 Feb 2003 08:58:14 GMT
    Here is a small proof of concept which

    - detects whether sendfile(64) are available on the platform
      at run-time
    - uses sendfile up to its maximum, if sendfile64 does not
      exist

    The attached a.out was built from ap_sendfile.c on a
    x86/glibc-2.2 box.

    strace with glibc-2.3:

    open("testfile", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0600) = 3
    pwrite(3, "a", 1, 2147483647)           = 1
    open("/dev/null", O_WRONLY)             = 4
    sendfile64(4, 3, [2147463648], 10000)   = 10000
    sendfile64(4, 3, [2147473648], 10000)   = 10000

    and on glibc-2.2:

    open("testfile", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0600) = 3
    pwrite(3, "a", 1, 2147483647)           = 1
    open("/dev/null", O_WRONLY)             = 4
    sendfile(4, 3, [2147463648], 10000)     = 10000
    pread(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384, 2147473648)
= 10000
    write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 10000) = 10000

    - Sascha
Mime
View raw message