dev  

Re: sendfile in darwin

Jim Jagielski
Thu, 08 May 2008 06:12:15 -0700


On May 7, 2008, at 5:58 PM, Geoff Greer wrote:

OK, so there are two problems here:

1. Timeout sockets are broken in r654185. To test this cd to apr/test,
make, then run

./sendfile server & ./sendfile client timeout

I cannot confirm that. Works fine here.

<jimsys:dev/apr-1.3/test> % ./sendfile server & ./sendfile client timeout
[1] 20908
Creating a test file...
Waiting for a client to connect...
Processing a client...
Sending the file...
Calling apr_socket_sendfile()...
Headers (3):
        15 bytes (1)
        5 bytes (E)
        80000 bytes (^)
File: 200000 bytes from offset 0
Trailers (3):
        19 bytes
        10 bytes
        90000 bytes
apr_socket_sendfile()->0, sent 370049 bytes
After apr_socket_sendfile(), the kernel file pointer is at offset 0.
server: apr_socket_sendfile() worked as expected!
client: apr_socket_sendfile() worked as expected!
[1]  + done       ./sendfile server
<jimsys:dev/apr-1.3/test> % ./sendfile server & ./sendfile client blocking
[1] 20936
Creating a test file...
Waiting for a client to connect...
Sending the file...
Processing a client...
apr_socket_sendfile() updated offset with 0
apr_socket_sendfile() updated len with 370049
bytes really sent: 370049
After apr_socket_sendfile(), the kernel file pointer is at offset 0.
server: apr_socket_sendfile() worked as expected!
client: apr_socket_sendfile() worked as expected!
[1]  + done       ./sendfile server
<jimsys:dev/apr-1.3/test> % ./sendfile server & ./sendfile client nonblocking
[1] 20964
Creating a test file...
Waiting for a client to connect...
Sending the file...
Processing a client...
Calling apr_socket_sendfile()...
Headers (3):
        15 bytes (1)
        5 bytes (E)
        80000 bytes (^)
File: 200000 bytes from offset 0
Trailers (3):
        19 bytes
        10 bytes
        90000 bytes
apr_socket_sendfile()->0, sent 370049 bytes
After apr_socket_sendfile(), the kernel file pointer is at offset 0.
server: apr_socket_sendfile() worked as expected!
client: apr_socket_sendfile() worked as expected!
[1]  + done       ./sendfile server


<jimsys:/Users/jim> % uname -a
Darwin jimsys.jaguNET.com 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386
<jimsys:/Users/jim> % gcc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.