dev  

Re: sendfile in darwin

Jim Jagielski
Tue, 13 May 2008 13:03:48 -0700


On May 13, 2008, at 2:59 PM, William A. Rowe, Jr. wrote:

Jim Jagielski wrote:
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.
Still broken here, see attached.

<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

Darwin Macintosh.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:23:43 PST 2008; root:xnu-1228.4.31~1/RELEASE_PPC Power Macintosh

Creating a test file...
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 223061 bytes
Calling apr_socket_sendfile()...
Headers (0):
File: 56959 bytes from offset 143041
Trailers (3):
        19 bytes
        10 bytes
        90000 bytes
apr_socket_sendfile()->0, sent 146988 bytes
After apr_socket_sendfile(), the kernel file pointer is at offset 0.
client: apr_socket_sendfile() worked as expected!
apr_socket_recv()->0/Undefined error: 0 (expected APR_EOF)
Waiting for a client to connect...
Processing a client...

From the ordering of the output, is the server side having enough time to start?
Shouldn't it be:

  Waiting for a client to connect...
  Creating a test file...
  Sending the file...
  Processing a client...
  apr_socket_sendfile() updated offset with 200000
  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!

I wonder if you are seeing timing issues rather than "real" errors...
See if:

  ./sendfile server & ./sendfile client timeout

behaves differently from

  ./sendfile server &
  ./sendfile client timeout

as well as:

  ./sendfile server &
  sleep 3
  ./sendfile client timeout