httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: A tiny correction and a question on writev_it_all
Date Sun, 07 Dec 1997 19:40:50 GMT

On Sun, 7 Dec 1997, Igor Tatarinov wrote:

> In buff.c :: writev_it_all() we have
>         /* recalculate vec to deal with partial writes */
>         while (rv > 0) {
>             if (rv < vec[i].iov_len) {
>                 vec[i].iov_base = (char *) vec[i].iov_base + rv;
>                 vec[i].iov_len -= rv;
>                 rv = 0;
> *                if (vec[i].iov_len == 0) {
> *                    ++i;
> *                }
>             }
>             else {
>                 rv -= vec[i].iov_len;
>                 ++i;
>             }
>         }
> Apparently, the marked lines are never executed since 
> the first if's condition is: rv < vec[i].iov_len. 
> Dont' know if it's worth changing though :)

Yeah they could be removed. 

> My question is: can I call writev_it_all directly from my module's handler
> (without calling bwrite)? 
> (I don't quite understand yet when that "chunking",etc stuff is used.
> I need vector I/O to send files from my cache (files are stored in blocks))

Well... no, it's static.  There is no writev()-style interface exported
from BUFF yet, but there should be.  BTW, like the mmap handling, you
shouldn't write too much in one go because of the way timeouts are

chunking is needed when the response is in HTTP/1.1 and the content-length
isn't known beforehand.  It's pretty easy to chunk a writev() call though,
you just add up the lengths beforehand.  You don't have to allow for
recovering from write failures or recovering from an EAGAIN -- because
bwrite() doesn't currently deal with them either. 

Oh yeah something else to consider is solaris 2.6 zero-copy TCP.  It
requires the right hardware (sun's atm card), and software needs to do the
right thing.  The "right thing" is: mmap() on a 16k boundary (the defaults
get this), and write() in n*16k chunks.  They goofed and don't support
writev() in 2.6 ... so for apache 1.3, where we writev() the headers along
with the first 32k of an mmap()ed file, we don't get zero-copy.  But we do
get zero-copy on subsequent 32k chunks. 

I talked with their engineer that wrote the kernel code and he knows what
we do/need so in the future it should be fixed.  I've also made sure the
folks working on the similar extensions for linux know about how apache
does its thing.

Now if only someone would make an intelligent 100baseTX card.  I'd love a
quad-port DEC tulip card with a StrongARM and 16Mb+ RAM on board.  Not
only could you implement a kick-ass router with that, but you could use it
to do zero-copy TCP with checksum on card and yadda yadda. 


View raw message